diff --git a/client/coral-embed-stream/src/tabs/stream/containers/CommentBox.js b/client/coral-embed-stream/src/tabs/stream/containers/CommentBox.js index f16a410ad..a64356578 100644 --- a/client/coral-embed-stream/src/tabs/stream/containers/CommentBox.js +++ b/client/coral-embed-stream/src/tabs/stream/containers/CommentBox.js @@ -1,8 +1,9 @@ import React from 'react'; import PropTypes from 'prop-types'; -import t from 'coral-framework/services/i18n'; +import t, { timeago } from 'coral-framework/services/i18n'; import { can } from 'coral-framework/services/perms'; +import { isSuspended } from 'coral-framework/utils/user'; import Slot from 'coral-framework/components/Slot'; import { connect } from 'react-redux'; @@ -40,6 +41,17 @@ class CommentBox extends React.Component { currentUser, } = this.props; + if (isSuspended(currentUser)) { + notify( + 'error', + t( + 'error.temporarily_suspended', + timeago(currentUser.status.suspension.until) + ) + ); + return; + } + if (!can(currentUser, 'INTERACT_WITH_COMMUNITY')) { notify('error', t('error.NOT_AUTHORIZED')); return; diff --git a/client/coral-framework/utils/user.js b/client/coral-framework/utils/user.js index f50fca335..93dcd4db9 100644 --- a/client/coral-framework/utils/user.js +++ b/client/coral-framework/utils/user.js @@ -21,7 +21,7 @@ export const getReliability = reliabilityValue => { */ export const isSuspended = user => { - const suspensionUntil = get(user, 'state.status.suspension.until'); + const suspensionUntil = get(user, 'status.suspension.until'); return user && suspensionUntil && new Date(suspensionUntil) > new Date(); }; diff --git a/locales/en.yml b/locales/en.yml index 97c37cc2f..1494ae28a 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -236,6 +236,7 @@ en: password: "Password must be at least 8 characters" username: "Usernames can contain letters numbers and _ only" unexpected: "Unexpected error occurred. Sorry!" + temporarily_suspended: "Your account is currently suspended. It will be reactivated {0}. Please contact us if you have any questions." flag_comment: "Report comment" flag_reason: "Reason for reporting (Optional)" flag_username: "Report username"