FIX: hide chat button in user card (#29887)

when the user isn't able to receive DMs (either because they've disabled it or because they're suspended for example).

Internal ref - t/142198
This commit is contained in:
Régis Hanol 2024-11-22 09:05:58 +01:00 committed by GitHub
parent 5bf5d13356
commit d71016522e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View File

@ -82,6 +82,8 @@ export default class CoreFabricators {
name: args.name,
avatar_template: "/letter_avatar_proxy/v3/letter/t/41988e/{size}.png",
suspended_till: args.suspended_till,
can_send_private_message_to_user:
args.can_send_private_message_to_user ?? true,
});
}

View File

@ -10,7 +10,10 @@ export default class ChatDirectMessageButton extends Component {
@service router;
get shouldRender() {
return this.chat.userCanDirectMessage && !this.args.user.suspended;
return (
this.chat.userCanDirectMessage &&
this.args.user.can_send_private_message_to_user
);
}
@action

View File

@ -39,13 +39,13 @@ module(
.doesNotExist("it doesnt show the chat button");
});
test("when displayed user is suspended", async function (assert) {
test("when displayed user has disabled PMs / DMs", async function (assert) {
sinon
.stub(this.owner.lookup("service:chat"), "userCanDirectMessage")
.value(true);
this.user = new CoreFabricators(getOwner(this)).user({
suspended_till: moment().add(1, "year").toDate(),
can_send_private_message_to_user: false,
});
await render(