From 51e172cd23423aff7f916dc3849259136b0dc7bd Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 4 Jun 2021 09:29:53 +0200 Subject: [PATCH] MOBILE-3320 messages: Fix no error displayed when blocking some users --- scripts/langindex.json | 1 + src/addons/messages/lang.json | 1 + src/addons/messages/pages/discussion/discussion.page.ts | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/scripts/langindex.json b/scripts/langindex.json index 044c28f95..79e24efe1 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -237,6 +237,7 @@ "addon.messages.blocknoncontacts": "message", "addon.messages.blockuser": "message", "addon.messages.blockuserconfirm": "message", + "addon.messages.cantblockuser": "message", "addon.messages.contactableprivacy": "message", "addon.messages.contactableprivacy_coursemember": "message", "addon.messages.contactableprivacy_onlycontacts": "message", diff --git a/src/addons/messages/lang.json b/src/addons/messages/lang.json index a6c556cda..b63ffa55c 100644 --- a/src/addons/messages/lang.json +++ b/src/addons/messages/lang.json @@ -7,6 +7,7 @@ "blocknoncontacts": "Prevent non-contacts from messaging me", "blockuser": "Block user", "blockuserconfirm": "Are you sure you want to block {{$a}}?", + "cantblockuser": "You can't block {{$a}} because they have a role with permission to message all users.", "contactableprivacy": "Accept messages from:", "contactableprivacy_coursemember": "My contacts and anyone in my courses", "contactableprivacy_onlycontacts": "My contacts only", diff --git a/src/addons/messages/pages/discussion/discussion.page.ts b/src/addons/messages/pages/discussion/discussion.page.ts index 41f353973..e107f5756 100644 --- a/src/addons/messages/pages/discussion/discussion.page.ts +++ b/src/addons/messages/pages/discussion/discussion.page.ts @@ -1446,6 +1446,12 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView throw new CoreError('No member selected to be blocked.'); } + if (this.otherMember.canmessageevenifblocked) { + CoreDomUtils.showErrorModal(Translate.instant('addon.messages.cantblockuser', { $a: this.otherMember.fullname })); + + return; + } + const template = Translate.instant('addon.messages.blockuserconfirm', { $a: this.otherMember.fullname }); const okText = Translate.instant('addon.messages.blockuser');