Chatwoot/app/controllers/api/v1/webhooks_controller.rb
Sojan Jose ab54d9c629
chore: Upgrade rails and ruby versions (#2400)
ruby version: 3.0.2
rails version: 6.1.4
2021-08-03 20:11:52 +05:30

28 lines
664 B
Ruby

class Api::V1::WebhooksController < ApplicationController
skip_before_action :authenticate_user!, raise: false
skip_before_action :set_current_user
def twitter_crc
render json: { response_token: "sha256=#{twitter_client.generate_crc(params[:crc_token])}" }
end
def twitter_events
twitter_consumer.consume
head :ok
rescue StandardError => e
Sentry.capture_exception(e)
head :ok
end
private
def twitter_client
Twitty::Facade.new do |config|
config.consumer_secret = ENV.fetch('TWITTER_CONSUMER_SECRET', nil)
end
end
def twitter_consumer
@twitter_consumer ||= ::Webhooks::Twitter.new(params)
end
end