FEATURE: Show similar users when penalizing a user (#19334)

* FEATURE: Show similar users when penalizing a user

Moderators will be notified if other users with the same IP address
exist before penalizing a user.

* FEATURE: Allow staff to penalize multiple users

This allows staff members to suspend or silence multiple users belonging
to the same person.
This commit is contained in:
Bianca Nenciu
2022-12-08 14:42:33 +02:00
committed by GitHub
parent ae40965896
commit 187b0bfb43
13 changed files with 259 additions and 56 deletions

View File

@@ -0,0 +1,29 @@
import Component from "@ember/component";
import { action } from "@ember/object";
import discourseComputed from "discourse-common/utils/decorators";
export default Component.extend({
tagName: "",
@discourseComputed("type")
penaltyField(penaltyType) {
if (penaltyType === "suspend") {
return "can_be_suspended";
} else if (penaltyType === "silence") {
return "can_be_silenced";
}
},
@action
selectUserId(userId, event) {
if (!this.selectedUserIds) {
return;
}
if (event.target.checked) {
this.selectedUserIds.pushObject(userId);
} else {
this.selectedUserIds.removeObject(userId);
}
},
});

View File

@@ -9,7 +9,11 @@ export default Controller.extend(PenaltyController, {
onShow() {
this.resetModal();
this.setProperties({ silenceUntil: null, silencing: false });
this.setProperties({
silenceUntil: null,
silencing: false,
otherUserIds: [],
});
},
finishedSetup() {
@@ -36,6 +40,7 @@ export default Controller.extend(PenaltyController, {
post_id: this.postId,
post_action: this.postAction,
post_edit: this.postEdit,
other_user_ids: this.otherUserIds,
});
}).finally(() => this.set("silencing", false));
},

View File

@@ -9,7 +9,11 @@ export default Controller.extend(PenaltyController, {
onShow() {
this.resetModal();
this.setProperties({ suspendUntil: null, suspending: false });
this.setProperties({
suspendUntil: null,
suspending: false,
otherUserIds: [],
});
},
finishedSetup() {
@@ -28,7 +32,6 @@ export default Controller.extend(PenaltyController, {
}
this.set("suspending", true);
this.penalize(() => {
return this.user.suspend({
suspend_until: this.suspendUntil,
@@ -37,6 +40,7 @@ export default Controller.extend(PenaltyController, {
post_id: this.postId,
post_action: this.postAction,
post_edit: this.postEdit,
other_user_ids: this.otherUserIds,
});
}).finally(() => this.set("suspending", false));
},

View File

@@ -0,0 +1,35 @@
<div class="penalty-similar-users">
<p class="alert alert-danger">
{{i18n "admin.user.other_matches" (hash count=this.user.similar_users_count username=this.user.username)}}
</p>
<table class="table">
<thead>
<tr>
<th></th>
<th>{{i18n "username"}}</th>
<th>{{i18n "last_seen"}}</th>
<th>{{i18n "admin.user.topics_entered"}}</th>
<th>{{i18n "admin.user.posts_read_count"}}</th>
<th>{{i18n "admin.user.time_read"}}</th>
<th>{{i18n "created"}}</th>
</tr>
</thead>
<tbody>
{{#each this.user.similar_users as |user|}}
<tr>
<td>
<Input @type="checkbox" disabled={{not (get user this.penaltyField)}} {{on "click" (action "selectUserId" user.id)}} />
</td>
<td>{{avatar user imageSize="small"}} {{user.username}}</td>
<td>{{format-duration user.last_seen_age}}</td>
<td>{{number user.topics_entered}}</td>
<td>{{number user.posts_read_count}}</td>
<td>{{format-duration user.time_read}}</td>
<td>{{format-duration user.created_at_age}}</td>
</tr>
{{/each}}
</tbody>
</table>
</div>

View File

@@ -18,6 +18,10 @@
<PenaltyPostAction @postId={{this.postId}} @postAction={{this.postAction}} @postEdit={{this.postEdit}} />
{{/if}}
{{#if this.user.similar_users}}
<AdminPenaltySimilarUsers @type="silence" @user={{this.user}} @selectedUserIds={{this.otherUserIds}} />
{{/if}}
</ConditionalLoadingSpinner>
</DModalBody>

View File

@@ -13,12 +13,15 @@
<FutureDateInput @class="suspend-until" @label="admin.user.suspend_duration" @clearable={{false}} @input={{this.suspendUntil}} @onChangeInput={{action (mut this.suspendUntil)}} />
</label>
</div>
<SuspensionDetails @reason={{this.reason}} @message={{this.message}} />
<SuspensionDetails @reason={{this.reason}} @message={{this.message}} />
{{#if this.postId}}
<PenaltyPostAction @postId={{this.postId}} @postAction={{this.postAction}} @postEdit={{this.postEdit}} />
{{/if}}
{{#if this.user.similar_users}}
<AdminPenaltySimilarUsers @type="suspend" @user={{this.user}} @selectedUserIds={{this.otherUserIds}} />
{{/if}}
{{else}}
<div class="cant-suspend">
{{i18n "admin.user.cant_suspend"}}