Skip to content

Commit

Permalink
Implement a message for user account suspension, as per MSC3823.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Yoric committed May 31, 2022
1 parent d7a6e3e commit b2b7c1f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
43 changes: 37 additions & 6 deletions src/components/structures/RoomStatusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,19 @@ export default class RoomStatusBar extends React.PureComponent<IProps, IState> {

let consentError = null;
let resourceLimitError = null;
let accountSuspendedError = null;
for (const m of unsentMessages) {
if (m.error && m.error.errcode === 'M_CONSENT_NOT_GIVEN') {
consentError = m.error;
break;
} else if (m.error && m.error.errcode === 'M_RESOURCE_LIMIT_EXCEEDED') {
resourceLimitError = m.error;
break;
if (m.error) {
if (m.error.errcode === 'M_CONSENT_NOT_GIVEN') {
consentError = m.error;
break;
} else if (m.error.errcode === 'M_RESOURCE_LIMIT_EXCEEDED') {
resourceLimitError = m.error;
break;
} else if (m.error.errcode === 'ORG.MATRIX.MSC3823.USER_ACCOUNT_SUSPENDED') {
accountSuspendedError = m.error;
break;
}
}
}
if (consentError) {
Expand Down Expand Up @@ -231,6 +237,31 @@ export default class RoomStatusBar extends React.PureComponent<IProps, IState> {
),
},
);
} else if (accountSuspendedError) {
const homeserverDomain: string = this.context.getDomain();
if (accountSuspendedError?.href) {
// Normally, all account suspension errors should contain a field `href` with details.
title = _t(
"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.",
{
homeserverDomain,
},
{
'detailsLink': (sub) =>
<a href={accountSuspendedError.href} target="_blank">
{sub}
</a>,
},
);
} else {
// ...just in case, let's display a less useful error message if `href` is missing.
title = _t(
"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.",
{
homeserverDomain,
},
);
}
} else {
title = _t('Some of your messages have not been sent');
}
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -3015,6 +3015,8 @@
"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.",
"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.",
"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.",
"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.",
"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.",
"Some of your messages have not been sent": "Some of your messages have not been sent",
"Delete all": "Delete all",
"Retry all": "Retry all",
Expand Down

0 comments on commit b2b7c1f

Please sign in to comment.