Sha256: bc548468f5407898d4735c84fd49b17662b14c6f675422d68e2ef907cc5ae5b9

Contents?: true

Size: 864 Bytes

Versions: 1

Compression:

Stored size: 864 Bytes

Contents

require_dependency "ishapi/application_controller"

module Ishapi
  class EmailMessagesController < ApplicationController

    before_action :check_jwt, only: [ :show ]

    def show

      m = Office::EmailMessage.find( params[:id] )
      authorize! :email_messages_show, ::Ishapi
      render json: {
        item: m,
      }
    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 )
        render status: :ok, json: { status: :ok }
      else
        render status: 400, json: { status: 400 }
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ishapi-0.1.8.213 app/controllers/ishapi/email_messages_controller.rb