Feature: Support account/inbox specific webhooks (#562)
This commit is contained in:
@@ -50,6 +50,7 @@ class Message < ApplicationRecord
|
||||
belongs_to :inbox
|
||||
belongs_to :conversation
|
||||
belongs_to :user, required: false
|
||||
belongs_to :contact, required: false
|
||||
|
||||
has_one :attachment, dependent: :destroy, autosave: true
|
||||
|
||||
@@ -78,6 +79,21 @@ class Message < ApplicationRecord
|
||||
incoming? || outgoing?
|
||||
end
|
||||
|
||||
def webhook_data
|
||||
{
|
||||
id: id,
|
||||
content: content,
|
||||
created_at: created_at,
|
||||
message_type: message_type,
|
||||
source_id: source_id,
|
||||
sender: user.try(:webhook_data),
|
||||
contact: contact.try(:webhook_data),
|
||||
inbox: inbox.webhook_data,
|
||||
conversation: conversation.webhook_data,
|
||||
account: account.webhook_data
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def dispatch_event
|
||||
|
||||
Reference in New Issue
Block a user