Sha256: 52f2dede49c0dc98161ff1312ae9bbdfcff8c25671df512a34093357b0a25469
Contents?: true
Size: 1.61 KB
Versions: 56
Compression:
Stored size: 1.61 KB
Contents
# typed: false # frozen_string_literal: true # Send updated data to Yetto to store in the database # This can be used to update installation data or message data module Hephaestus class UpdateYettoJob < ApplicationJob queue_as :high_priority_update_yetto def perform(params) type = params.delete(:type) params.deep_symbolize_keys! inbox_id = params.fetch(:inbox, {}).fetch(:id, nil) plug_installation_id = params.fetch(:plug_installation, {}).fetch(:id, nil) conversation_id = params.fetch(:conversation, {}).fetch(:id, nil) message_id = params.fetch(:message, {}).fetch(:id, nil) response = case type when "update_plug_installation" YettoService.update_plug_installation(plug_installation_id, params[:payload]) when "create_conversation" YettoService.create_conversation(plug_installation_id, inbox_id, params[:payload]) when "add_message_to_conversation" YettoService.add_message_to_conversation(plug_installation_id, conversation_id, params[:payload]) when "create_message_reply" YettoService.create_message_reply(plug_installation_id, message_id, params[:payload]) when "update_message" YettoService.update_message(plug_installation_id, message_id, params[:payload]) end response, type = Rails.configuration.enhance_update_yetto_job.call(params, type, response) if Rails.configuration.respond_to?(:enhance_update_yetto_job) if response.present? && response.unavailable? logger.error("Could not #{type} for #{plug_installation_id}: #{response.parsed_json_body}") end end end end
Version data entries
56 entries across 56 versions & 1 rubygems