Enhancement: Add event name in webhook payload (#528)
* chore: Remove unwanted twitter gem * Enhancement: Add event name in webhook payload fixes #528 #516 #518
This commit is contained in:
parent
813cdd8aec
commit
d36e1b52f6
4 changed files with 3 additions and 28 deletions
1
Gemfile
1
Gemfile
|
@ -61,7 +61,6 @@ gem 'chargebee'
|
||||||
##--- gems for channels ---##
|
##--- gems for channels ---##
|
||||||
gem 'facebook-messenger'
|
gem 'facebook-messenger'
|
||||||
gem 'telegram-bot-ruby'
|
gem 'telegram-bot-ruby'
|
||||||
gem 'twitter'
|
|
||||||
# twitty will handle subscription of twitter account events
|
# twitty will handle subscription of twitter account events
|
||||||
gem 'twitty', git: 'https://github.com/chatwoot/twitty'
|
gem 'twitty', git: 'https://github.com/chatwoot/twitty'
|
||||||
|
|
||||||
|
|
24
Gemfile.lock
24
Gemfile.lock
|
@ -109,7 +109,6 @@ GEM
|
||||||
msgpack (~> 1.0)
|
msgpack (~> 1.0)
|
||||||
brakeman (4.7.2)
|
brakeman (4.7.2)
|
||||||
browser (3.0.3)
|
browser (3.0.3)
|
||||||
buftok (0.2.0)
|
|
||||||
builder (3.2.4)
|
builder (3.2.4)
|
||||||
bullet (6.1.0)
|
bullet (6.1.0)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
|
@ -203,16 +202,9 @@ GEM
|
||||||
signet (~> 0.12)
|
signet (~> 0.12)
|
||||||
haikunator (1.1.0)
|
haikunator (1.1.0)
|
||||||
hashie (4.1.0)
|
hashie (4.1.0)
|
||||||
http (3.3.0)
|
|
||||||
addressable (~> 2.3)
|
|
||||||
http-cookie (~> 1.0)
|
|
||||||
http-form_data (~> 2.0)
|
|
||||||
http_parser.rb (~> 0.6.0)
|
|
||||||
http-accept (1.7.0)
|
http-accept (1.7.0)
|
||||||
http-cookie (1.0.3)
|
http-cookie (1.0.3)
|
||||||
domain_name (~> 0.5)
|
domain_name (~> 0.5)
|
||||||
http-form_data (2.2.0)
|
|
||||||
http_parser.rb (0.6.0)
|
|
||||||
httparty (0.17.3)
|
httparty (0.17.3)
|
||||||
mime-types (~> 3.0)
|
mime-types (~> 3.0)
|
||||||
multi_xml (>= 0.5.2)
|
multi_xml (>= 0.5.2)
|
||||||
|
@ -259,8 +251,6 @@ GEM
|
||||||
marcel (0.3.3)
|
marcel (0.3.3)
|
||||||
mimemagic (~> 0.3.2)
|
mimemagic (~> 0.3.2)
|
||||||
memoist (0.16.2)
|
memoist (0.16.2)
|
||||||
memoizable (0.4.2)
|
|
||||||
thread_safe (~> 0.3, >= 0.3.1)
|
|
||||||
method_source (0.9.2)
|
method_source (0.9.2)
|
||||||
mime-types (3.3.1)
|
mime-types (3.3.1)
|
||||||
mime-types-data (~> 3.2015)
|
mime-types-data (~> 3.2015)
|
||||||
|
@ -275,7 +265,6 @@ GEM
|
||||||
multi_json (1.14.1)
|
multi_json (1.14.1)
|
||||||
multi_xml (0.6.0)
|
multi_xml (0.6.0)
|
||||||
multipart-post (2.1.1)
|
multipart-post (2.1.1)
|
||||||
naught (1.1.0)
|
|
||||||
netrc (0.11.0)
|
netrc (0.11.0)
|
||||||
nightfury (1.0.1)
|
nightfury (1.0.1)
|
||||||
nio4r (2.5.2)
|
nio4r (2.5.2)
|
||||||
|
@ -419,7 +408,6 @@ GEM
|
||||||
faraday (~> 0.9)
|
faraday (~> 0.9)
|
||||||
jwt (>= 1.5, < 3.0)
|
jwt (>= 1.5, < 3.0)
|
||||||
multi_json (~> 1.10)
|
multi_json (~> 1.10)
|
||||||
simple_oauth (0.3.1)
|
|
||||||
simplecov (0.17.1)
|
simplecov (0.17.1)
|
||||||
docile (~> 1.1)
|
docile (~> 1.1)
|
||||||
json (>= 1.8, < 3)
|
json (>= 1.8, < 3)
|
||||||
|
@ -445,17 +433,6 @@ GEM
|
||||||
time_diff (0.3.0)
|
time_diff (0.3.0)
|
||||||
activesupport
|
activesupport
|
||||||
i18n
|
i18n
|
||||||
twitter (6.2.0)
|
|
||||||
addressable (~> 2.3)
|
|
||||||
buftok (~> 0.2.0)
|
|
||||||
equalizer (~> 0.0.11)
|
|
||||||
http (~> 3.0)
|
|
||||||
http-form_data (~> 2.0)
|
|
||||||
http_parser.rb (~> 0.6.0)
|
|
||||||
memoizable (~> 0.4.0)
|
|
||||||
multipart-post (~> 2.0)
|
|
||||||
naught (~> 1.0)
|
|
||||||
simple_oauth (~> 0.3.0)
|
|
||||||
tzinfo (1.2.6)
|
tzinfo (1.2.6)
|
||||||
thread_safe (~> 0.1)
|
thread_safe (~> 0.1)
|
||||||
tzinfo-data (1.2019.3)
|
tzinfo-data (1.2019.3)
|
||||||
|
@ -556,7 +533,6 @@ DEPENDENCIES
|
||||||
spring-watcher-listen
|
spring-watcher-listen
|
||||||
telegram-bot-ruby
|
telegram-bot-ruby
|
||||||
time_diff
|
time_diff
|
||||||
twitter
|
|
||||||
twitty!
|
twitty!
|
||||||
tzinfo-data
|
tzinfo-data
|
||||||
uglifier
|
uglifier
|
||||||
|
|
|
@ -6,7 +6,7 @@ class WebhookListener < BaseListener
|
||||||
return unless message.reportable? && inbox.webhook.present?
|
return unless message.reportable? && inbox.webhook.present?
|
||||||
|
|
||||||
webhook = message.inbox.webhook
|
webhook = message.inbox.webhook
|
||||||
payload = message.push_event_data
|
payload = message.push_event_data.merge(event: __method__.to_s)
|
||||||
|
|
||||||
webhook.urls.each do |url|
|
webhook.urls.each do |url|
|
||||||
WebhookJob.perform_later(url, payload)
|
WebhookJob.perform_later(url, payload)
|
||||||
|
|
|
@ -24,8 +24,8 @@ describe WebhookListener do
|
||||||
|
|
||||||
context 'when webhook is configured' do
|
context 'when webhook is configured' do
|
||||||
it 'triggers webhook' do
|
it 'triggers webhook' do
|
||||||
create(:webhook, inbox: inbox, account: account)
|
webhook = create(:webhook, inbox: inbox, account: account)
|
||||||
expect(WebhookJob).to receive(:perform_later).once
|
expect(WebhookJob).to receive(:perform_later).with(webhook.urls[0], message.push_event_data.merge(event: 'message_created')).once
|
||||||
listener.message_created(event)
|
listener.message_created(event)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue