7b1fdc5fcd
BugFix: Filter duplicate DMs in Twitter Integration
25 lines
473 B
Ruby
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
|