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:
parent
5bf5d13356
commit
d71016522e
|
@ -82,6 +82,8 @@ export default class CoreFabricators {
|
||||||
name: args.name,
|
name: args.name,
|
||||||
avatar_template: "/letter_avatar_proxy/v3/letter/t/41988e/{size}.png",
|
avatar_template: "/letter_avatar_proxy/v3/letter/t/41988e/{size}.png",
|
||||||
suspended_till: args.suspended_till,
|
suspended_till: args.suspended_till,
|
||||||
|
can_send_private_message_to_user:
|
||||||
|
args.can_send_private_message_to_user ?? true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,10 @@ export default class ChatDirectMessageButton extends Component {
|
||||||
@service router;
|
@service router;
|
||||||
|
|
||||||
get shouldRender() {
|
get shouldRender() {
|
||||||
return this.chat.userCanDirectMessage && !this.args.user.suspended;
|
return (
|
||||||
|
this.chat.userCanDirectMessage &&
|
||||||
|
this.args.user.can_send_private_message_to_user
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
|
|
@ -39,13 +39,13 @@ module(
|
||||||
.doesNotExist("it doesn’t show the chat button");
|
.doesNotExist("it doesn’t 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
|
sinon
|
||||||
.stub(this.owner.lookup("service:chat"), "userCanDirectMessage")
|
.stub(this.owner.lookup("service:chat"), "userCanDirectMessage")
|
||||||
.value(true);
|
.value(true);
|
||||||
|
|
||||||
this.user = new CoreFabricators(getOwner(this)).user({
|
this.user = new CoreFabricators(getOwner(this)).user({
|
||||||
suspended_till: moment().add(1, "year").toDate(),
|
can_send_private_message_to_user: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
await render(
|
await render(
|
||||||
|
|
Loading…
Reference in New Issue