diff --git a/app/javascript/shared/helpers/MessageFormatter.js b/app/javascript/shared/helpers/MessageFormatter.js index 8f97e559d..78b21d330 100644 --- a/app/javascript/shared/helpers/MessageFormatter.js +++ b/app/javascript/shared/helpers/MessageFormatter.js @@ -10,7 +10,7 @@ const TWITTER_HASH_REGEX = /(^|\s)#(\w+)/g; const TWITTER_HASH_REPLACEMENT = '$1#$2'; -const USER_MENTIONS_REGEX = /mention:\/\/(user|team)\/(\d+)\/([\w\s]+)/gm; +const USER_MENTIONS_REGEX = /mention:\/\/(user|team)\/(\d+)\/(.+)/gm; class MessageFormatter { constructor(message, isATweet = false) { diff --git a/app/listeners/notification_listener.rb b/app/listeners/notification_listener.rb index f591dd671..0fe10b739 100644 --- a/app/listeners/notification_listener.rb +++ b/app/listeners/notification_listener.rb @@ -56,7 +56,8 @@ class NotificationListener < BaseListener def generate_notifications_for_mentions(message, account) return unless message.private? - mentioned_ids = message.content.scan(%r{\(mention://(user|team)/(\d+)/([\w\s]+)\)}).map(&:second).uniq + mentioned_ids = message.content.scan(%r{\(mention://(user|team)/(\d+)/(.+)\)}).map(&:second).uniq + return if mentioned_ids.blank? get_valid_mentioned_ids(mentioned_ids, message.inbox).each do |user_id| diff --git a/spec/listeners/notification_listener_spec.rb b/spec/listeners/notification_listener_spec.rb index 10a936d5a..8a80cd82f 100644 --- a/spec/listeners/notification_listener_spec.rb +++ b/spec/listeners/notification_listener_spec.rb @@ -59,12 +59,15 @@ describe NotificationListener do allow(builder).to receive(:perform) create(:inbox_member, user: agent_with_notification, inbox: inbox) - create(:inbox_member, user: agent_with_out_notification, inbox: inbox) conversation.reload - message = build(:message, conversation: conversation, account: account, - content: "hi [#{agent_with_notification.name}](mention://user/#{agent_with_notification.id}/\ - #{agent_with_notification.name})", private: true) + message = build( + :message, + conversation: conversation, + account: account, + content: "hi [#{agent_with_notification.name}](mention://user/#{agent_with_notification.id}/#{agent_with_notification.name})", + private: true + ) event = Events::Base.new(event_name, Time.zone.now, message: message) listener.message_created(event)