Chatwoot/lib/webhooks/twitter.rb
Pranav Raj S 7b1fdc5fcd
BugFix: Filter duplicate DMs in Twitter Integration (#468)
BugFix: Filter duplicate DMs in Twitter Integration
2020-02-05 18:50:37 +05:30

25 lines
473 B
Ruby

# frozen_string_literal: true
class Webhooks::Twitter
SUPPORTED_EVENTS = [:direct_message_events].freeze
attr_accessor :params, :account
def initialize(params)
@params = params
end
def consume
send(event_name) if event_name
end
private
def event_name
@event_name ||= SUPPORTED_EVENTS.find { |key| @params.key?(key.to_s) }
end
def direct_message_events
::Twitter::DirectMessageParserService.new(payload: @params).perform
end
end