Sha256: 15cbc64e2a43cd9e97c9acb7e809c3df17ab0556bfe7246235cb3dadeefdfaf4

Contents?: true

Size: 872 Bytes

Versions: 2

Compression:

Stored size: 872 Bytes

Contents

require_dependency "ishapi/application_controller"

module Ishapi
  class EmailMessagesController < ApplicationController

    before_action :check_jwt, only: [ :show ]

    def show
      msg = Office::EmailMessage.find( params[:id] )
      authorize! :email_messages_show, ::Ishapi
      render json: {
        item: msg,
      }
    end

    ## From lambda, ses
    def receive
      if params[:secret] != AWS_SES_LAMBDA_SECRET
        render status: 400, json: { status: 400 }
        return
      end

      msg = Office::EmailMessageStub.new({
        object_path: params[:object_path],
        object_key:  params[:object_key],
      })
      if msg.save
        ::Ishapi::EmailMessageIntakeJob.perform_later( msg.id.to_s )
        render status: :ok, json: { status: :ok }
      else
        render status: 400, json: { status: 400 }
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ishapi-0.1.8.215 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.214 app/controllers/ishapi/email_messages_controller.rb