Class: WcoEmail::Api::MessagesController
- Inherits:
-
WcoEmail::ApiController
- Object
- WcoEmail::ApiController
- WcoEmail::Api::MessagesController
- Defined in:
- app/controllers/wco_email/api/messages_controller.rb
Instance Method Summary collapse
-
#create_postal ⇒ Object
2026-03-27 payload is parsed json.
- #create_ses ⇒ Object
-
#postal_webhook ⇒ Object
{ "message": { "id": 1778, "direction": "outgoing", "message_id": "6a595d99629a1_7dfe84558@245533f3cb05.mail", "to": "poxlovi@gmail.com", "from": "no-reply@wasya.co", "subject": "tasty 16d test", "timestamp": 1784241561.520441, "spam_status": "NotChecked", "tag": null }, "status": "Sent", "details": "Message for poxlovi@gmail.com accepted by 142.251.2.27:25 (gmail-smtp-in.l.google.com)", "output": "250 2.0.0 OK 1784241562 5a478bee46e88-3142a267131si91362eec.61 - gsmtp", "sent_with_ssl": true, "timestamp": 1784241562.9551728, "time": 0.64 }.
Instance Method Details
#create_postal ⇒ Object
2026-03-27 payload is parsed json.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/wco_email/api/messages_controller.rb', line 9 def create_postal # puts! params, 'api/messages#create_postal' ## save to bucket @client ||= Aws::S3::Client.new(::SES_S3_CREDENTIALS) @client.put_object({ body: params.to_unsafe_h.to_json, bucket: ::SES_S3_BUCKET, content_type: 'application/json', key: params['message_id'], }) stub = WcoEmail::MessageStub.create!({ bucket: ::SES_S3_BUCKET, format: 'json', object_key: params['message_id'], }) WcoEmail::MessageIntakeJob.perform_async( stub.id.to_s ) render status: :ok, json: { status: :ok } end |
#create_ses ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/wco_email/api/messages_controller.rb', line 31 def create_ses # puts! params, 'params' stub = WcoEmail::MessageStub.find_or_create_by({ bucket: params[:bucket], format: 'raw', object_key: params[:object_key], }) WcoEmail::MessageIntakeJob.perform_async( stub.id.to_s ) render status: :ok, json: { status: :ok } end |
#postal_webhook ⇒ Object
{ "message": { "id": 1778, "direction": "outgoing", "message_id": "6a595d99629a1_7dfe84558@245533f3cb05.mail", "to": "poxlovi@gmail.com", "from": "no-reply@wasya.co", "subject": "tasty 16d test", "timestamp": 1784241561.520441, "spam_status": "NotChecked", "tag": null }, "status": "Sent", "details": "Message for poxlovi@gmail.com accepted by 142.251.2.27:25 (gmail-smtp-in.l.google.com)", "output": "250 2.0.0 OK 1784241562 5a478bee46e88-3142a267131si91362eec.61 - gsmtp", "sent_with_ssl": true, "timestamp": 1784241562.9551728, "time": 0.64 }
{ "message": { "id": 1786, "token": "P6V8T55pRllHYS2w", "direction": "outgoing", "message_id": "6a595dcc152e2_7dea8459f5@245533f3cb05.mail", "to": "robferrell1@hotmail.com", "from": "no-reply@wasya.co", "subject": "Using cursor is infuriating - AI makes you dumb", "timestamp": 1784241612.205367, "spam_status": "NotChecked", "tag": null }, "status": "HardFail", "details": "Permanent SMTP delivery error when sending to 52.101.68.20:25 (hotmail-com.olc.protection.outlook.com)", "output": "550 5.7.1 Unfortunately, messages from [167.172.221.28] weren't sent. Please contact your Internet service provider since part of their network is on our block list (S3140). You can also refer your provider to http://mail.live.com/mail/troubleshootin", "sent_with_ssl": false, "timestamp": 1784241616.289614, "time": 0.13 }
88 89 90 91 92 93 94 95 96 |
# File 'app/controllers/wco_email/api/messages_controller.rb', line 88 def postal_webhook if 'HardFail' == params['status'] lead = Wco::Lead.where( email: params['message']['to'].downcase ).first if lead lead..push Wco::Tag.bounce lead.save end end end |