mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-15 01:49:10 +00:00
feat(Server): invalidate caches on changes
This commit is contained in:
parent
0e70e2590b
commit
4ffd5014df
3 changed files with 32 additions and 2 deletions
|
@ -89,7 +89,11 @@ module.exports = (R, $) => {
|
|||
...(categories != null ? { categories } : {}),
|
||||
})
|
||||
|
||||
|
||||
ctx.body = { ok: true }
|
||||
|
||||
$.P.invalidate(id)
|
||||
$.discord.invalidate(id)
|
||||
})
|
||||
|
||||
R.get('/api/admin/servers', async ctx => {
|
||||
|
@ -131,8 +135,16 @@ module.exports = (R, $) => {
|
|||
// last, add new roles
|
||||
newRoles = [...newRoles, ...sanitizedAdded]
|
||||
|
||||
await $.discord.updateRoles(gm, newRoles)
|
||||
if (!arrayMatches(currentRoles, newRoles)) {
|
||||
await $.discord.updateRoles(gm, newRoles)
|
||||
}
|
||||
|
||||
ctx.body = { ok: true }
|
||||
|
||||
$.P.invalidate(userId)
|
||||
$.discord.invalidate(userId)
|
||||
})
|
||||
}
|
||||
|
||||
const arrayMatches = (a, b) =>
|
||||
a.length === b.length && a.reduce((_, aValue) => b.contains(aValue), true)
|
Loading…
Add table
Add a link
Reference in a new issue