Skip to content

Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬

591 B
Raw Blame
class Webhooks::TwilioEventsJob < ApplicationJob
  queue_as :low

  def perform(params = {})
    # Skip processing if Body parameter, MediaUrl0, or location data is not present
    # This is to skip processing delivery events being delivered to this endpoint
    return if params[:Body].blank? && params[:MediaUrl0].blank? && !valid_location_message?(params)

    ::Twilio::IncomingMessageService.new(params: params).perform
  end

  private

  def valid_location_message?(params)
    params[:MessageType] == 'location' && params[:Latitude].present? && params[:Longitude].present?
  end
end