Discord chat bot to announce projects (#590)

* Add support for discord chat bot to announce when images are set, with instructions on configuring for dev

* Tweak discord bot message.

Co-authored-by: Kurt Hutten <k.hutten@protonmail.ch>
This commit was merged in pull request #590.
This commit is contained in:
Scott Martin
2022-01-13 15:11:30 -05:00
committed by GitHub
parent 82dd3d2555
commit 90fece9598
7 changed files with 146 additions and 8 deletions

View File

@@ -12,6 +12,8 @@ import {
} from 'src/services/helpers'
import { requireAuth } from 'src/lib/auth'
import { requireOwnership, requireProjectOwnership } from 'src/lib/owner'
import { sendDiscordMessage } from 'src/lib/discord'
export const projects = ({ userName }) => {
if (!userName) {
@@ -243,7 +245,19 @@ export const updateProjectImages = async ({
const [updatedProject] = await Promise.all([
projectPromise,
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
}