mirror of
https://github.com/fergalmoran/onearmy-community-platform.git
synced 2025-12-22 09:37:54 +00:00
feat: make a webhook for when a question is accepted
This commit is contained in:
@@ -64,3 +64,38 @@ export const notifyNewHowTo = functions
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
export const notifyAcceptedQuestion = functions
|
||||
.runWith({ memory: '512MB' })
|
||||
.firestore.document('questions_rev20230926/{id}')
|
||||
.onCreate((snapshot) => {
|
||||
const info = snapshot.data()
|
||||
console.log(info)
|
||||
|
||||
const username = info._createdBy
|
||||
const title = info.title
|
||||
const slug = info.slug
|
||||
|
||||
const moderation = info.moderation
|
||||
|
||||
if (moderation !== IModerationStatus.ACCEPTED) {
|
||||
return
|
||||
}
|
||||
|
||||
request.post(
|
||||
SLACK_WEBHOOK_URL,
|
||||
{
|
||||
json: {
|
||||
text: `❓ ${username} has a new question: ${title}\n Help them out and answer here: ${SITE_URL}/questions/${slug}`,
|
||||
},
|
||||
},
|
||||
(error, response) => {
|
||||
if (error) {
|
||||
console.error(error)
|
||||
return
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
@@ -4,6 +4,7 @@ import * as IntegrationsPatreon from './patreon'
|
||||
|
||||
exports.notifyNewPin = IntegrationsSlack.notifyNewPin
|
||||
exports.notifyNewHowTo = IntegrationsSlack.notifyNewHowTo
|
||||
exports.notifyAcceptedQuestion = IntegrationsSlack.notifyAcceptedQuestion
|
||||
exports.notifyPinAccepted = IntegrationsDiscord.notifyPinAccepted
|
||||
exports.notifyHowToAccepted = IntegrationsDiscord.notifyHowToAccepted
|
||||
exports.patreonAuth = IntegrationsPatreon.patreonAuth
|
||||
|
||||
Reference in New Issue
Block a user