Skip to content

Commit b2b7c1f

Browse files
committed
Implement a message for user account suspension, as per MSC3823.
Users may have their account temporarily suspended from a homeserver, e.g. due to ToS violations. This prevents them from sending new messages but not from logging, reading messages or redacting their own messages. This patch displays an error message comparable to "some of your messages have not been sent". See matrix-org/synapse#12845 for more details. Notes: Support for MSC3823. Display an error message if the user's account has been suspended.
1 parent d7a6e3e commit b2b7c1f

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

src/components/structures/RoomStatusBar.tsx

+37-6
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,19 @@ export default class RoomStatusBar extends React.PureComponent<IProps, IState> {
191191

192192
let consentError = null;
193193
let resourceLimitError = null;
194+
let accountSuspendedError = null;
194195
for (const m of unsentMessages) {
195-
if (m.error && m.error.errcode === 'M_CONSENT_NOT_GIVEN') {
196-
consentError = m.error;
197-
break;
198-
} else if (m.error && m.error.errcode === 'M_RESOURCE_LIMIT_EXCEEDED') {
199-
resourceLimitError = m.error;
200-
break;
196+
if (m.error) {
197+
if (m.error.errcode === 'M_CONSENT_NOT_GIVEN') {
198+
consentError = m.error;
199+
break;
200+
} else if (m.error.errcode === 'M_RESOURCE_LIMIT_EXCEEDED') {
201+
resourceLimitError = m.error;
202+
break;
203+
} else if (m.error.errcode === 'ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED') {
204+
accountSuspendedError = m.error;
205+
break;
206+
}
201207
}
202208
}
203209
if (consentError) {
@@ -231,6 +237,31 @@ export default class RoomStatusBar extends React.PureComponent<IProps, IState> {
231237
),
232238
},
233239
);
240+
} else if (accountSuspendedError) {
241+
const homeserverDomain: string = this.context.getDomain();
242+
if (accountSuspendedError?.href) {
243+
// Normally, all account suspension errors should contain a field `href` with details.
244+
title = _t(
245+
"Your message wasn't sent because your user account on %(homeserverDomain)s has been suspended. Please see <detailsLink>this page</detailsLink> for more details on why your account was suspended and for information on getting it restored.",
246+
{
247+
homeserverDomain,
248+
},
249+
{
250+
'detailsLink': (sub) =>
251+
<a href={accountSuspendedError.href} target="_blank">
252+
{sub}
253+
</a>,
254+
},
255+
);
256+
} else {
257+
// ...just in case, let's display a less useful error message if `href` is missing.
258+
title = _t(
259+
"Your message wasn't sent because your user account on %(homeserverDomain)s has been suspended. Please get in touch with the administrator of %(homeserverDomain)s for more details.",
260+
{
261+
homeserverDomain,
262+
},
263+
);
264+
}
234265
} else {
235266
title = _t('Some of your messages have not been sent');
236267
}

src/i18n/strings/en_EN.json

+2
Original file line numberDiff line numberDiff line change
@@ -3015,6 +3015,8 @@
30153015
"Your message wasn't sent because this homeserver has hit its Monthly Active User Limit. Please <a>contact your service administrator</a> to continue using the service.": "Your message wasn't sent because this homeserver has hit its Monthly Active User Limit. Please <a>contact your service administrator</a> to continue using the service.",
30163016
"Your message wasn't sent because this homeserver has been blocked by it's administrator. Please <a>contact your service administrator</a> to continue using the service.": "Your message wasn't sent because this homeserver has been blocked by it's administrator. Please <a>contact your service administrator</a> to continue using the service.",
30173017
"Your message wasn't sent because this homeserver has exceeded a resource limit. Please <a>contact your service administrator</a> to continue using the service.": "Your message wasn't sent because this homeserver has exceeded a resource limit. Please <a>contact your service administrator</a> to continue using the service.",
3018+
"Your message wasn't sent because your user account on %(homeserverDomain)s has been suspended. Please see <detailsLink>this page</detailsLink> for more details on why your account was suspended and for information on getting it restored.": "Your message wasn't sent because your user account on %(homeserverDomain)s has been suspended. Please see <detailsLink>this page</detailsLink> for more details on why your account was suspended and for information on getting it restored.",
3019+
"Your message wasn't sent because your user account on %(homeserverDomain)s has been suspended. Please get in touch with the administrator of %(homeserverDomain)s for more details.": "Your message wasn't sent because your user account on %(homeserverDomain)s has been suspended. Please get in touch with the administrator of %(homeserverDomain)s for more details.",
30183020
"Some of your messages have not been sent": "Some of your messages have not been sent",
30193021
"Delete all": "Delete all",
30203022
"Retry all": "Retry all",

0 commit comments

Comments
 (0)