diff --git a/website/client/src/components/admin-panel/user-support/privilegesAndGems.vue b/website/client/src/components/admin-panel/user-support/privilegesAndGems.vue index 9de6873469..69f12a64e3 100644 --- a/website/client/src/components/admin-panel/user-support/privilegesAndGems.vue +++ b/website/client/src/components/admin-panel/user-support/privilegesAndGems.vue @@ -40,6 +40,11 @@ v-model="hero.auth.blocked" type="checkbox" > Ban / Block +

+ + Banning a user also auto-hides all their guild posts. + +

diff --git a/website/client/src/components/userMenu/profile.vue b/website/client/src/components/userMenu/profile.vue index b270d6cf69..e577ee85f4 100644 --- a/website/client/src/components/userMenu/profile.vue +++ b/website/client/src/components/userMenu/profile.vue @@ -1028,9 +1028,10 @@ export default { this.$store.dispatch('hall:updateHero', { heroDetails: this.hero }); }, adminBlockUser () { - this.hero.auth.blocked = true; - - this.$store.dispatch('hall:updateHero', { heroDetails: this.hero }); + if (window.confirm('Ban user and auto-hide all posts?')) { + this.hero.auth.blocked = true; + this.$store.dispatch('hall:updateHero', { heroDetails: this.hero }); + } }, adminUnblockUser () { this.hero.auth.blocked = false; diff --git a/website/server/controllers/api-v3/hall.js b/website/server/controllers/api-v3/hall.js index ba9310bef8..6140a37ac1 100644 --- a/website/server/controllers/api-v3/hall.js +++ b/website/server/controllers/api-v3/hall.js @@ -9,6 +9,7 @@ import { NotFound, } from '../../libs/errors'; import apiError from '../../libs/apiError'; +import { flagAllMessages } from '../../libs/chat/group-chat'; import { validateItemPath, castItemVal, @@ -336,6 +337,7 @@ api.updateHero = { if (updateData.auth && updateData.auth.blocked === true) { hero.auth.blocked = updateData.auth.blocked; hero.preferences.sleep = true; // when blocking, have them rest at an inn to prevent damage + await flagAllMessages(hero); } if (updateData.auth && updateData.auth.blocked === false) { hero.auth.blocked = false; diff --git a/website/server/libs/chat/group-chat.js b/website/server/libs/chat/group-chat.js index dc6b0d8278..5acad5855c 100644 --- a/website/server/libs/chat/group-chat.js +++ b/website/server/libs/chat/group-chat.js @@ -114,3 +114,9 @@ export function translateMessage (lang, info) { } return msg; } + +export async function flagAllMessages (user) { + const bulk = Chat.collection.initializeOrderedBulkOp(); + bulk.find({ uuid: user._id }).update({ $set: { flagCount: 3 } }); + await bulk.execute(); +}