fix: attachment rendering if the message content is empty in private note (#1831)
Fixes #1830
This commit is contained in:
parent
00954aa16f
commit
aab70bf1f1
2 changed files with 32 additions and 5 deletions
|
@ -56,6 +56,8 @@ class NotificationListener < BaseListener
|
|||
def generate_notifications_for_mentions(message, account)
|
||||
return unless message.private?
|
||||
|
||||
return if message.content.blank?
|
||||
|
||||
mentioned_ids = message.content.scan(%r{\(mention://(user|team)/(\d+)/(.+)\)}).map(&:second).uniq
|
||||
|
||||
return if mentioned_ids.blank?
|
||||
|
|
|
@ -47,13 +47,15 @@ describe NotificationListener do
|
|||
describe 'message_created' do
|
||||
let(:event_name) { :'message.created' }
|
||||
|
||||
before do
|
||||
notification_setting = agent_with_notification.notification_settings.find_by(account_id: account.id)
|
||||
notification_setting.selected_email_flags = [:email_conversation_mention]
|
||||
notification_setting.selected_push_flags = []
|
||||
notification_setting.save!
|
||||
end
|
||||
|
||||
context 'when message contains mention' do
|
||||
it 'creates notifications for inbox member who was mentioned' do
|
||||
notification_setting = agent_with_notification.notification_settings.find_by(account_id: account.id)
|
||||
notification_setting.selected_email_flags = [:email_conversation_mention]
|
||||
notification_setting.selected_push_flags = []
|
||||
notification_setting.save!
|
||||
|
||||
builder = double
|
||||
allow(NotificationBuilder).to receive(:new).and_return(builder)
|
||||
allow(builder).to receive(:perform)
|
||||
|
@ -78,5 +80,28 @@ describe NotificationListener do
|
|||
primary_actor: message)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when message content is empty' do
|
||||
it 'creates notifications' do
|
||||
builder = double
|
||||
allow(NotificationBuilder).to receive(:new).and_return(builder)
|
||||
allow(builder).to receive(:perform)
|
||||
|
||||
create(:inbox_member, user: agent_with_notification, inbox: inbox)
|
||||
conversation.reload
|
||||
|
||||
message = build(
|
||||
:message,
|
||||
conversation: conversation,
|
||||
account: account,
|
||||
content: nil,
|
||||
private: true
|
||||
)
|
||||
|
||||
event = Events::Base.new(event_name, Time.zone.now, message: message)
|
||||
# want to validate message_created doesnt throw an error
|
||||
expect(listener.message_created(event)).to eq nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue