Sha256: e85a85211202e357076dab73732be4e3e5330d72c837d1daf1f7c59ab359000c
Contents?: true
Size: 1.91 KB
Versions: 26
Compression:
Stored size: 1.91 KB
Contents
# typed: false # frozen_string_literal: true class AppController < ApplicationController include Authable include Constants::PlugApp include PathParameter::AppParameters include BodyParameter::AppParameters before_action :from_app? # Inbound message from ${App} def webhook # Error if necessary parameters from ${App} are missing return bad_request unless has_inbound_app_params? response = YettoService.get_plug_installation(pparam_organization_id, pparam_inbox_id, pparam_plug_installation_id) # Error if Yetto is down return service_unavailable(response) if response.unavailable? plug_installation = response.parse_json_body installed_on_inbox = plug_installation.fetch("installed_on_inbox", {}) organization = installed_on_inbox.fetch("organization", {}) # Bail if the organization is not active return forbidden unless organization.fetch("status", "") == "active" plug_id = plug_installation.fetch("plug", {}).fetch("id", "") inbox_id = installed_on_inbox.fetch("id", "") organization_id = organization.fetch("id", "") return bad_request if plug_id.blank? || inbox_id.blank? # Send the message to Yetto update_data = { type: "create_message", inbox: { id: inbox_id }, organization: { id: organization_id }, payload: { creator: { id: plug_id, }, message: { title: title, text_content: text_body, is_public: true, author: { version: "2023-03-06", name: from_email, }, attachments: bparam_attachments, metadata: { cc_addresses: cc_addresses, postmark_message_id: bparam_message_id, email_message_id: email_message_id, }, }, }, } UpdateYettoJob.perform_later(update_data) created end def process_inbound no_content end end
Version data entries
26 entries across 26 versions & 1 rubygems