mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-29 18:22:53 +00:00
26 lines
569 B
Ruby
26 lines
569 B
Ruby
class Messages::NewMessageNotificationService
|
|
pattr_initialize [:message!]
|
|
|
|
def perform
|
|
return unless message.notifiable?
|
|
|
|
notify_conversation_assignee
|
|
end
|
|
|
|
private
|
|
|
|
delegate :conversation, :sender, :account, to: :message
|
|
|
|
def notify_conversation_assignee
|
|
return if conversation.assignee.blank?
|
|
return if conversation.assignee == sender
|
|
|
|
NotificationBuilder.new(
|
|
notification_type: 'assigned_conversation_new_message',
|
|
user: conversation.assignee,
|
|
account: account,
|
|
primary_actor: message
|
|
).perform
|
|
end
|
|
end
|