Kurt/revert discord to attempt deploy (#598)
* Force netlify build builds are being canceled even though there are changes * Revert "Upgrade packages (#594)" This reverts commit5531f2e0c1. * Revert "Discord chat bot to announce projects (#590)" This reverts commit90fece9598. * Revert "Force netlify build" This reverts commit315ebf0c59. * Make sure project title is robust
This commit was merged in pull request #598.
This commit is contained in:
@@ -59,27 +59,6 @@ localUser2@kurthutten.com: `abc123`
|
|||||||
|
|
||||||
localAdmin@kurthutten.com: `abc123`
|
localAdmin@kurthutten.com: `abc123`
|
||||||
|
|
||||||
### Discord bot setup
|
|
||||||
|
|
||||||
To set up the discord bot to notify when users publish new content (see also [the discord JS tutorial](https://discordjs.guide/preparations/setting-up-a-bot-application.html)):
|
|
||||||
|
|
||||||
1. If you're setting up the bot in a dev environment, create a new discord server (the "plus" button on the left when logged into the Discord webpage). Make note of the name of the project.
|
|
||||||
2. With [developer mode turned on](https://www.howtogeek.com/714348/how-to-enable-or-disable-developer-mode-on-discord/), right click the channel you wish the bot to announce on and select "Copy ID". Add this to `.env.defaults` as `DISCORD_CHANNEL_ID`.
|
|
||||||
3. [create a new application](https://discord.com/developers/applications), or navigate to an existing one.
|
|
||||||
4. Create a bot within that application. Copy the bot token and add it to `.env.defaults` as `DISCORD_TOKEN`.
|
|
||||||
5. Go to the "URL Generator" under "OAuth2" and create a URL with scope "bot" and text permission "Send Messages".
|
|
||||||
6. Copy the generated URL and open it in a new tab. Follow the instructions on the page to add the bot to your discord server.
|
|
||||||
|
|
||||||
When you next start CADHub, you should see in the logs `Discord: logged in as <bot name>` and you should see a startup message from the bot in the channel.
|
|
||||||
|
|
||||||
To send messages as the bot when things happen in the service, use the `sendChat` helper function:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
import { sendChat } from 'src/lib/discord'
|
|
||||||
|
|
||||||
sendChat("hello world!")
|
|
||||||
```
|
|
||||||
|
|
||||||
## Designs
|
## Designs
|
||||||
|
|
||||||
In progress, though can be [seen on Figma](https://www.figma.com/file/VUh53RdncjZ7NuFYj0RGB9/CadHub?node-id=0%3A1)
|
In progress, though can be [seen on Figma](https://www.figma.com/file/VUh53RdncjZ7NuFYj0RGB9/CadHub?node-id=0%3A1)
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ CLOUDINARY_API_KEY=476712943135152
|
|||||||
# trace | info | debug | warn | error | silent
|
# trace | info | debug | warn | error | silent
|
||||||
# LOG_LEVEL=debug
|
# LOG_LEVEL=debug
|
||||||
|
|
||||||
|
|
||||||
# EMAIL_PASSWORD=abc123
|
# EMAIL_PASSWORD=abc123
|
||||||
# DISCORD_TOKEN=abc123
|
|
||||||
# DISCORD_CHANNEL_ID=12345
|
|
||||||
|
|
||||||
# CAD_LAMBDA_BASE_URL="http://localhost:8080"
|
# CAD_LAMBDA_BASE_URL="http://localhost:8080"
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"cloudinary": "^1.23.0",
|
"cloudinary": "^1.23.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"discord.js": "^13.5.1",
|
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"human-id": "^2.0.1",
|
"human-id": "^2.0.1",
|
||||||
"middy": "^0.36.0",
|
"middy": "^0.36.0",
|
||||||
@@ -22,4 +21,4 @@
|
|||||||
"concurrently": "^6.0.0",
|
"concurrently": "^6.0.0",
|
||||||
"nodemon": "^2.0.7"
|
"nodemon": "^2.0.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
import {Client, Intents, MessageAttachment} from "discord.js"
|
|
||||||
|
|
||||||
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]})
|
|
||||||
|
|
||||||
export async function sendDiscordMessage(text: string, url?: string) {
|
|
||||||
if (!client.isReady()) {
|
|
||||||
console.error(`Discord: client is not ready to send message ("${text}")`);
|
|
||||||
} else {
|
|
||||||
const channel = await client.channels.fetch(process.env.DISCORD_CHANNEL_ID);
|
|
||||||
if (url) {
|
|
||||||
channel.send({ embeds: [{
|
|
||||||
title: text,
|
|
||||||
image: {
|
|
||||||
url: url,
|
|
||||||
},
|
|
||||||
}] });
|
|
||||||
|
|
||||||
} else {
|
|
||||||
channel.send(text)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
client.on("ready", async () => {
|
|
||||||
console.log(`Discord: logged in as ${client.user.tag}`)
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!process.env.DISCORD_TOKEN || !process.env.DISCORD_CHANNEL_ID) {
|
|
||||||
console.warn("Discord bot not configured - please set process.env.DISCORD_TOKEN and process.env.DISCORD_CHANNEL_ID to send discord chats");
|
|
||||||
} else {
|
|
||||||
console.log(`Discord: logging in (token ${process.env.DISCORD_TOKEN})`);
|
|
||||||
client.login(process.env.DISCORD_TOKEN);
|
|
||||||
}
|
|
||||||
@@ -12,8 +12,6 @@ import {
|
|||||||
} from 'src/services/helpers'
|
} from 'src/services/helpers'
|
||||||
import { requireAuth } from 'src/lib/auth'
|
import { requireAuth } from 'src/lib/auth'
|
||||||
import { requireOwnership, requireProjectOwnership } from 'src/lib/owner'
|
import { requireOwnership, requireProjectOwnership } from 'src/lib/owner'
|
||||||
import { sendDiscordMessage } from 'src/lib/discord'
|
|
||||||
|
|
||||||
|
|
||||||
export const projects = ({ userName }) => {
|
export const projects = ({ userName }) => {
|
||||||
if (!userName) {
|
if (!userName) {
|
||||||
@@ -245,19 +243,7 @@ export const updateProjectImages = async ({
|
|||||||
const [updatedProject] = await Promise.all([
|
const [updatedProject] = await Promise.all([
|
||||||
projectPromise,
|
projectPromise,
|
||||||
imageDestroyPromise,
|
imageDestroyPromise,
|
||||||
]).then(async (result) => {
|
])
|
||||||
const { userName } = await db.user.findUnique({
|
|
||||||
where: { id: project.userId },
|
|
||||||
})
|
|
||||||
sendDiscordMessage([
|
|
||||||
`${userName} just added an image to their ${project.cadPackage} project:`,
|
|
||||||
` => ${project.title}`,
|
|
||||||
``,
|
|
||||||
`Check it out, leave a comment, make them feel welcome!`,
|
|
||||||
`https://cadhub.xyz/u/${userName}/${project.title}`
|
|
||||||
].join('\n'), `https://res.cloudinary.com/irevdev/image/upload/c_scale,w_700/v1/${mainImage}`)
|
|
||||||
return result
|
|
||||||
})
|
|
||||||
return updatedProject
|
return updatedProject
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,4 +36,4 @@
|
|||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "yarn rw exec seed"
|
"seed": "yarn rw exec seed"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
'SENTRY_AUTH_TOKEN',
|
'SENTRY_AUTH_TOKEN',
|
||||||
'SENTRY_ORG',
|
'SENTRY_ORG',
|
||||||
'SENTRY_PROJECT',
|
'SENTRY_PROJECT',
|
||||||
'EMAIL_PASSWORD',
|
'EMAIL_PASSWORD'
|
||||||
]
|
]
|
||||||
# experimentalFastRefresh = true # this seems to break cascadeStudio
|
# experimentalFastRefresh = true # this seems to break cascadeStudio
|
||||||
[api]
|
[api]
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ export const Success = ({ userProject, refetch }) => {
|
|||||||
ideType: state.ideType,
|
ideType: state.ideType,
|
||||||
geometry: state.objectData?.data,
|
geometry: state.objectData?.data,
|
||||||
quality: state.objectData?.quality,
|
quality: state.objectData?.quality,
|
||||||
fileName: `${userProject.Project.title }.stl`,
|
fileName: `${userProject.Project?.title }.stl`,
|
||||||
thunkDispatch,
|
thunkDispatch,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
5569
app/yarn.lock
5569
app/yarn.lock
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user