Skip to content

Commit

Permalink
Relay and beautify 'blocked words' error message
Browse files Browse the repository at this point in the history
  • Loading branch information
infinite-persistence committed May 10, 2021
1 parent b8f6c7c commit b11d163
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions static/app-strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,8 @@
"Controversial": "Controversial",
"Show Replies": "Show Replies",
"Unable to create comment, please try again later.": "Unable to create comment, please try again later.",
"Unable to comment. This channel has blocked you.": "Unable to comment. This channel has blocked you.",
"The comment contains contents that are blocked by %author%": "The comment contains contents that are blocked by %author%",
"Your channel is still being setup, try again in a few moments.": "Your channel is still being setup, try again in a few moments.",
"Unable to delete this comment, please try again later.": "Unable to delete this comment, please try again later.",
"Unable to edit this comment, please try again later.": "Unable to edit this comment, please try again later.",
Expand Down
11 changes: 11 additions & 0 deletions ui/redux/actions/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,17 @@ export function doCommentCreate(
toastMessage = __('Unable to comment. This channel has blocked you.');
}

if (error) {
const BLOCKED_WORDS_ERR_MSG = 'the comment contents are blocked by';

if (error.message === 'channel is blocked by publisher') {
toastMessage = __('Unable to comment. This channel has blocked you.');
} else if (error.message.startsWith(BLOCKED_WORDS_ERR_MSG)) {
const channelName = error.message.substring(BLOCKED_WORDS_ERR_MSG.length);
toastMessage = __('The comment contains contents that are blocked by %author%', { author: channelName });
}
}

dispatch(
doToast({
message: toastMessage,
Expand Down

0 comments on commit b11d163

Please sign in to comment.