FIX: Show error message if user is already silenced or suspended (#10988)

Users could be silenced or suspended by two staff members at the same time and
would not be aware of it. This commit shows an error message if another penalty
has been applied.
This commit is contained in:
Bianca Nenciu
2020-11-03 17:38:56 +02:00
committed by GitHub
parent d384e744a8
commit d2116f0029
7 changed files with 78 additions and 14 deletions

View File

@ -352,28 +352,17 @@ const AdminUser = User.extend({
type: "PUT",
})
.then((result) => this.setProperties(result.unsilence))
.catch((e) => {
const error = I18n.t("admin.user.unsilence_failed", {
error: this._formatError(e),
});
bootbox.alert(error);
})
.finally(() => this.set("silencingUser", false));
},
silence(data) {
this.set("silencingUser", true);
return ajax(`/admin/users/${this.id}/silence`, {
type: "PUT",
data,
})
.then((result) => this.setProperties(result.silence))
.catch((e) => {
const error = I18n.t("admin.user.silence_failed", {
error: this._formatError(e),
});
bootbox.alert(error);
})
.finally(() => this.set("silencingUser", false));
},