feat(rolepicker): report on status passed up from discord service

This commit is contained in:
41666 2020-05-07 22:38:56 -04:00
parent 690671317f
commit 0c321e8b1e
No known key found for this signature in database
GPG key ID: BC51D07640DC10AF
9 changed files with 116 additions and 43 deletions

View file

@ -134,18 +134,27 @@ module.exports = (R, $) => {
// last, add new roles
newRoles = [...newRoles, ...sanitizedAdded]
if (!arrayMatches(currentRoles, newRoles)) {
if (process.env.FF_TransactionalRoles !== '0') {
await $.discord.updateRolesTx(gm, {
added: sanitizedAdded,
removed: sanitizedRemoved,
})
} else {
await $.discord.updateRoles(gm, newRoles)
let status = null
try {
if (!arrayMatches(currentRoles, newRoles)) {
if (process.env.FF_TransactionalRoles !== '0') {
const ret = await $.discord.updateRolesTx(gm, {
added: sanitizedAdded,
removed: sanitizedRemoved,
})
status = ret.toObject().status
} else {
await $.discord.updateRoles(gm, newRoles)
}
}
} catch (e) {
ctx.status = 400
ctx.body = { ok: false }
return
}
ctx.body = { ok: true }
ctx.body = { ok: true, status }
$.P.invalidate(userId)
$.discord.invalidate(userId)