Skip to content

Instantly share code, notes, and snippets.

@chrisallick
Created September 25, 2018 18:05
Show Gist options
  • Save chrisallick/ebebe5e5556a091fc62a31b8b1a620ab to your computer and use it in GitHub Desktop.
Save chrisallick/ebebe5e5556a091fc62a31b8b1a620ab to your computer and use it in GitHub Desktop.

Revisions

  1. chrisallick created this gist Sep 25, 2018.
    26 changes: 26 additions & 0 deletions email_sender.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    require 'aws-sdk-lambda' # https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/ruby/example_code/lambda/aws-ruby-sdk-lambda-example-run-function.rb

    require 'json'

    require 'sendgrid-ruby'
    include SendGrid # https://github.com/sendgrid/sendgrid-ruby

    Encoding.default_external = 'UTF-8'

    class EmailSender
    @queue = "email_sender_queue"

    def self.perform(data)
    puts "#{@@redis.get('test')}"
    puts data

    if data and data["note_attributes"] and data["note_attributes"].any?
    repeat = false

    all = Resque.redis.lrange("deliveries", 0, 20 )
    all.each do |oid|
    delivery_object = JSON.parse(Resque.redis.get("delivery:#{oid}"))
    if delivery_object["order_id"] == data["id"]
    puts "already sent!"
    end
    end