Sha256: 11a73e95532485fabb818ab22e3cd3b5c45ebf217d36435d320eaeff3fde3894

Contents?: true

Size: 1.18 KB

Versions: 65

Compression:

Stored size: 1.18 KB

Contents

require_dependency "ishapi/application_controller"

class ::Ishapi::EmailMessagesController < ::Ishapi::ApplicationController

  before_action :check_jwt, only: [ :show ]
  layout false

  def show
    @msg = Office::EmailMessage.find( params[:id] )
    authorize! :show, @msg

    if params[:load_images]
      ;
    else
      if @msg.part_html
        doc = Nokogiri::HTML(@msg.part_html)
        images = doc.search('img')
        images.each do |img|
          img['src'] = 'missing'
        end
        @msg.part_html = doc
      end
    end

    respond_to do |format|
      format.json do
        render json: { item: @msg, }
      end
      format.html do
      end
    end
  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_key:  params[:object_key],
    })
    if msg.save
      ::Ishapi::EmailMessageIntakeJob.perform_later( msg.id.to_s )
      render status: :ok, json: { status: :ok }
    else
      puts! msg.errors.full_messages, 'Could not save EmailMessageStub'
      render status: 400, json: { status: 400 }
    end
  end

end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
ishapi-0.1.8.316 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.315 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.314 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.313 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.312 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.310 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.309 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.308 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.307 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.306 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.305 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.304 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.303 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.302 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.301 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.300 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.298 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.297 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.296 app/controllers/ishapi/email_messages_controller.rb
ishapi-0.1.8.295 app/controllers/ishapi/email_messages_controller.rb