Compare commits

...

1 Commits

Author SHA1 Message Date
Phillip Thelen
a018588021 Banning a user now automatically hides all their posts 2022-12-09 13:02:49 +01:00
4 changed files with 17 additions and 3 deletions

View File

@@ -40,6 +40,11 @@
v-model="hero.auth.blocked"
type="checkbox"
> Ban / Block
<p>
<small>
Banning a user also auto-hides all their guild posts.
</small>
</p>
</label>
</div>
<div class="form-inline">

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();
}