diff --git a/app/components/post_draft/draft_input/draft_input.js b/app/components/post_draft/draft_input/draft_input.js
index 8a82a7cfd..e40a5b3b1 100644
--- a/app/components/post_draft/draft_input/draft_input.js
+++ b/app/components/post_draft/draft_input/draft_input.js
@@ -329,12 +329,13 @@ export default class DraftInput extends PureComponent {
const notificationsToChannel = enableConfirmNotificationsToChannel && useChannelMentions;
const notificationsToGroups = enableConfirmNotificationsToChannel && useGroupMentions;
const toAllOrChannel = DraftUtils.textContainsAtAllAtChannel(value);
- const groupMentions = (!toAllOrChannel && notificationsToGroups) ? DraftUtils.groupsMentionedInText(groupsWithAllowReference, value) : [];
+ const toHere = DraftUtils.textContainsAtHere(value);
+ const groupMentions = (!toAllOrChannel && !toHere && notificationsToGroups) ? DraftUtils.groupsMentionedInText(groupsWithAllowReference, value) : [];
if (value.indexOf('/') === 0) {
this.sendCommand(value);
- } else if (notificationsToChannel && membersCount > NOTIFY_ALL_MEMBERS && toAllOrChannel) {
- this.showSendToAllOrChannelAlert(membersCount, value);
+ } else if (notificationsToChannel && membersCount > NOTIFY_ALL_MEMBERS && (toAllOrChannel || toHere)) {
+ this.showSendToAllOrChannelOrHereAlert(membersCount, value, toHere && !toAllOrChannel);
} else if (groupMentions.length > 0) {
const {groupMentionsSet, memberNotifyCount, channelTimezoneCount} = DraftUtils.mapGroupMentions(channelMemberCountsByGroup, groupMentions);
if (memberNotifyCount > 0) {
@@ -364,11 +365,11 @@ export default class DraftInput extends PureComponent {
}
}
- showSendToAllOrChannelAlert = (membersCount, msg) => {
+ showSendToAllOrChannelOrHereAlert = (membersCount, msg, atHere) => {
const {formatMessage} = this.context.intl;
const {channelTimezoneCount} = this.state;
const {isTimezoneEnabled} = this.props;
- const notifyAllMessage = DraftUtils.buildChannelWideMentionMessage(formatMessage, membersCount, isTimezoneEnabled, channelTimezoneCount);
+ const notifyAllMessage = DraftUtils.buildChannelWideMentionMessage(formatMessage, membersCount, isTimezoneEnabled, channelTimezoneCount, atHere);
const cancel = () => {
this.setInputValue(msg);
this.setState({sendingMessage: false});
diff --git a/app/components/post_draft/draft_input/draft_input.test.js b/app/components/post_draft/draft_input/draft_input.test.js
index 5a21190b2..a48fbfac7 100644
--- a/app/components/post_draft/draft_input/draft_input.test.js
+++ b/app/components/post_draft/draft_input/draft_input.test.js
@@ -110,6 +110,31 @@ describe('DraftInput', () => {
expect(Alert.alert).toHaveBeenCalledWith('Confirm sending notifications to entire channel', expect.anything(), expect.anything());
});
+ test('should send an alert when sending a message with a @here mention', () => {
+ const wrapper = shallowWithIntl(
+ ,
+ );
+ const message = '@here';
+ const instance = wrapper.instance();
+ expect(instance.input).toEqual({current: null});
+ instance.input = {
+ current: {
+ getValue: () => message,
+ setValue: jest.fn(),
+ changeDraft: jest.fn(),
+ resetTextInput: jest.fn(),
+ },
+ };
+
+ instance.handleSendMessage();
+ jest.runOnlyPendingTimers();
+ expect(Alert.alert).toBeCalled();
+ expect(Alert.alert).toHaveBeenCalledWith('Confirm sending notifications to entire channel', expect.anything(), expect.anything());
+ });
+
test('should send an alert when sending a message with a group mention with group with count more than NOTIFY_ALL', () => {
const wrapper = shallowWithIntl(
{
return (/(?:\B|\b_+)@(channel|all)(?!(\.|-|_)*[^\W_])/i).test(textWithoutCode);
};
+export const textContainsAtHere = (text) => {
+ const textWithoutCode = text.replace(CODE_REGEX, '');
+ return (/(?:\B|\b_+)@(here)(?!(\.|-|_)*[^\W_])/i).test(textWithoutCode);
+};
+
export const badDeepLink = (intl) => {
const {formatMessage} = intl;
Alert.alert(
diff --git a/assets/base/i18n/en.json b/assets/base/i18n/en.json
index d95b8cd04..ecf435f81 100644
--- a/assets/base/i18n/en.json
+++ b/assets/base/i18n/en.json
@@ -482,6 +482,8 @@
"mobile.post_pre_header.flagged": "Saved",
"mobile.post_pre_header.pinned": "Pinned",
"mobile.post_pre_header.pinned_flagged": "Pinned and Saved",
+ "mobile.post_textbox.entire_channel_here.message": "By using @here you are about to send notifications to up to {totalMembers, number} {totalMembers, plural, one {person} other {people}}. Are you sure you want to do this?",
+ "mobile.post_textbox.entire_channel_here.message.with_timezones": "By using @here you are about to send notifications up to {totalMembers, number} {totalMembers, plural, one {person} other {people}} in {timezones, number} {timezones, plural, one {timezone} other {timezones}}. Are you sure you want to do this?",
"mobile.post_textbox.entire_channel.cancel": "Cancel",
"mobile.post_textbox.entire_channel.confirm": "Confirm",
"mobile.post_textbox.entire_channel.message": "By using @all or @channel you are about to send notifications to {totalMembers, number} {totalMembers, plural, one {person} other {people}}. Are you sure you want to do this?",