mirror of
https://github.com/fergalmoran/onearmy-community-platform.git
synced 2026-01-02 23:15:07 +00:00
chore: move code to discord file
This commit is contained in:
@@ -54,6 +54,31 @@ export const notifyHowToAccepted = functions
|
||||
.catch(handleErr)
|
||||
})
|
||||
|
||||
export const notifyAcceptedQuestion = functions
|
||||
.runWith({ memory: '512MB' })
|
||||
.firestore.document('questions_rev20230926/{id}')
|
||||
// currently, questions are immediately posted with no review.
|
||||
// if that changes, this code will need to be updated.
|
||||
.onCreate(async (snapshot) => {
|
||||
const info = snapshot.data()
|
||||
console.log(info)
|
||||
|
||||
const username = info._createdBy
|
||||
const title = info.title
|
||||
const slug = info.slug
|
||||
|
||||
try {
|
||||
const response = await axios.post(DISCORD_WEBHOOK_URL, {
|
||||
json: {
|
||||
text: `❓ ${username} has a new question: ${title}\n Help them out and answer here: ${SITE_URL}/questions/${slug}`,
|
||||
},
|
||||
})
|
||||
handleResponse(response)
|
||||
} catch (error) {
|
||||
handleErr(error)
|
||||
}
|
||||
})
|
||||
|
||||
const handleResponse = (res: AxiosResponse) => {
|
||||
console.log('post success')
|
||||
return res
|
||||
|
||||
@@ -7,7 +7,6 @@ const SITE_URL = CONFIG.deployment.site_url
|
||||
// e.g. https://dev.onearmy.world or https://community.preciousplastic.com
|
||||
|
||||
const SLACK_WEBHOOK_URL = CONFIG.integrations.slack_webhook
|
||||
const DISCORD_WEBHOOK_URL = CONFIG.integrations.discord_webhook
|
||||
|
||||
export const notifyNewPin = functions
|
||||
.runWith({ memory: '512MB' })
|
||||
@@ -65,34 +64,3 @@ export const notifyNewHowTo = functions
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
export const notifyAcceptedQuestion = functions
|
||||
.runWith({ memory: '512MB' })
|
||||
.firestore.document('questions_rev20230926/{id}')
|
||||
// currently, questions are immediately posted with no review.
|
||||
// if that changes, this code will need to change.
|
||||
.onCreate((snapshot) => {
|
||||
const info = snapshot.data()
|
||||
console.log(info)
|
||||
|
||||
const username = info._createdBy
|
||||
const title = info.title
|
||||
const slug = info.slug
|
||||
|
||||
request.post(
|
||||
DISCORD_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
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
@@ -8,6 +8,6 @@ exports.notifyPinAccepted = IntegrationsDiscord.notifyPinAccepted
|
||||
exports.notifyNewHowTo = IntegrationsSlack.notifyNewHowTo
|
||||
exports.notifyHowToAccepted = IntegrationsDiscord.notifyHowToAccepted
|
||||
|
||||
exports.notifyAcceptedQuestion = IntegrationsSlack.notifyAcceptedQuestion
|
||||
exports.notifyAcceptedQuestion = IntegrationsDiscord.notifyAcceptedQuestion
|
||||
|
||||
exports.patreonAuth = IntegrationsPatreon.patreonAuth
|
||||
|
||||
Reference in New Issue
Block a user