emailbutler 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb57bd8a59942207f28941dd14e91f17cd5d74982877773415a38b925d49ccaa
4
- data.tar.gz: 0fc748f32a49291175cccdff3a9e89dfe2aefafaacd1c357df38c545d18d768a
3
+ metadata.gz: e06b545b530403687a7844d31538ea50de73cffbc8f225ab5a849fe13d7678b0
4
+ data.tar.gz: c6fdc2b0fcf1afb430c0b1c80b2b1b89f9273007a54f97b3c96ddbad44a1bef2
5
5
  SHA512:
6
- metadata.gz: 0b5a8e3d1c292ff847623e7f404c5535d4324d9f206b0a15905b982fda3c42bd566039cb6e01727b085b7f924899ec07ffdd8a2d05e5fa418eba4d048f7012f1
7
- data.tar.gz: d1bed20baaadc9b02fe3b8e8f8d4412e575977121d376f2077e18adc35349f5db261c7216f98b0cd0b87a7f875041c7f5614d70cd0c5dc6fe0fd8c6f42091045
6
+ metadata.gz: 71919a2533d61eb98ea21ef74266c261f1569acaf8ae2193fa30eef083b2ae06c659ec38af299d86d67d5b09f06ed9391b7fd63ba143687bd2592d071bbac916
7
+ data.tar.gz: ea46055aa238b71c0c237138caf69e2ed8b4580d0956e95274e3762071b7ae72e273ddf6fc43147634d0723d8b5966b31b8a25d89b8ed71901937fa7c1f9e12a
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Emailbutler
2
2
  Simple email tracker for Ruby on Rails applications.
3
- Emailbutler allows you to track delivery status of emails sent by your app through Sendgrid and/or SMTP2GO.
3
+ Emailbutler allows you to track delivery status of emails sent by your app through Sendgrid, SMTP2GO, Resend.
4
4
 
5
5
  There are situations when you need to check whether a certain letter or certain type of letters was successfully sent from the application, and through the UI of some providers you can try to find such a letter by the recipient or the subject of the letter, but sometimes it's not enough.
6
6
 
@@ -34,7 +34,7 @@ require 'emailbutler/adapters/active_record'
34
34
 
35
35
  Emailbutler.configure do |config|
36
36
  config.adapter = Emailbutler::Adapters::ActiveRecord.new # required
37
- config.providers = %w[sendgrid smtp2go] # required at least 1 provider since 0.8
37
+ config.providers = %w[sendgrid smtp2go resend] # optional
38
38
  config.ui_username = 'username' # optional
39
39
  config.ui_password = 'password' # optional
40
40
  config.ui_secured_environments = ['production'] # optional
@@ -116,6 +116,14 @@ end
116
116
  - select all deliverability data,
117
117
  - save settings.
118
118
 
119
+ #### Resend
120
+
121
+ - go to [Mail settings](https://resend.com/webhooks),
122
+ - add Webhook,
123
+ - in the Endpoint URL field, paste the URL to webhook controller of your app (host/emailbutler/webhooks/resend),
124
+ - select all deliverability data,
125
+ - save settings.
126
+
119
127
  ## Usage
120
128
 
121
129
  1. Each event with sending email will create new record with message params in database.
@@ -37,6 +37,7 @@ module Emailbutler
37
37
  case params[:provider]
38
38
  when 'sendgrid' then Emailbutler::Container.resolve(:sendgrid_mapper)
39
39
  when 'smtp2go' then Emailbutler::Container.resolve(:smtp2go_mapper)
40
+ when 'resend' then Emailbutler::Container.resolve(:resend_mapper)
40
41
  end
41
42
  end
42
43
 
@@ -44,6 +45,7 @@ module Emailbutler
44
45
  case params[:provider]
45
46
  when 'sendgrid' then sendgrid_params
46
47
  when 'smtp2go' then smtp2go_params
48
+ when 'resend' then resend_params
47
49
  end
48
50
  end
49
51
 
@@ -55,6 +57,10 @@ module Emailbutler
55
57
  params.permit('event', 'sendtime', 'message-id')
56
58
  end
57
59
 
60
+ def resend_params
61
+ params.permit('type', 'created_at', 'data' => %w[email_id])
62
+ end
63
+
58
64
  def receiver_mapper_deprecated(user_agent)
59
65
  case user_agent
60
66
  when SENDGRID_USER_AGENT then Emailbutler::Container.resolve(:sendgrid_mapper)
@@ -7,7 +7,7 @@ module Emailbutler
7
7
  AVAILABLE_ADAPTERS = %w[
8
8
  Emailbutler::Adapters::ActiveRecord
9
9
  ].freeze
10
- AVAILABLE_PROVIDERS = %w[sendgrid smtp2go].freeze
10
+ AVAILABLE_PROVIDERS = %w[sendgrid smtp2go resend].freeze
11
11
 
12
12
  attr_accessor :adapter, :providers, :ui_username, :ui_password, :ui_secured_environments
13
13
 
@@ -39,7 +39,6 @@ module Emailbutler
39
39
 
40
40
  def validate_providers
41
41
  raise InitializeError, 'Providers list must be array' unless providers.is_a?(Array)
42
- raise InitializeError, 'At least 1 provider must be present' if providers.blank?
43
42
 
44
43
  return unless providers.any? { |provider| AVAILABLE_PROVIDERS.exclude?(provider) }
45
44
 
@@ -3,6 +3,7 @@
3
3
  require 'dry/container'
4
4
  require 'emailbutler/webhooks/mappers/sendgrid'
5
5
  require 'emailbutler/webhooks/mappers/smtp2go'
6
+ require 'emailbutler/webhooks/mappers/resend'
6
7
  require 'emailbutler/webhooks/receiver'
7
8
 
8
9
  module Emailbutler
@@ -20,6 +21,7 @@ module Emailbutler
20
21
  # webhook mappers
21
22
  register(:sendgrid_mapper) { Emailbutler::Webhooks::Mappers::Sendgrid.new }
22
23
  register(:smtp2go_mapper) { Emailbutler::Webhooks::Mappers::Smtp2Go.new }
24
+ register(:resend_mapper) { Emailbutler::Webhooks::Mappers::Resend.new }
23
25
 
24
26
  # webhook receiver
25
27
  register(:webhooks_receiver) { Emailbutler::Webhooks::Receiver.new }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Emailbutler
4
- VERSION = '0.8.0'
4
+ VERSION = '0.8.1'
5
5
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Emailbutler
4
+ module Webhooks
5
+ module Mappers
6
+ class Resend
7
+ DELIVERABILITY_MAPPER = {
8
+ 'email.sent' => 'processed',
9
+ 'email.delivered' => 'delivered',
10
+ 'email.opened' => 'delivered',
11
+ 'email.clicked' => 'delivered',
12
+ 'email.delivered_delayed' => 'failed',
13
+ 'email.bounced' => 'failed',
14
+ 'email.complained' => 'failed'
15
+ }.freeze
16
+
17
+ def call(payload:)
18
+ payload.stringify_keys!
19
+ # message-id contains data like <uuid>
20
+ message_uuid = payload.dig('data', 'email_id')
21
+ status = DELIVERABILITY_MAPPER[payload['type']]
22
+ return [] if message_uuid.nil? || status.nil?
23
+
24
+ [
25
+ {
26
+ message_uuid: message_uuid,
27
+ status: status,
28
+ timestamp: payload['created_at'] ? DateTime.parse(payload['created_at']).utc : nil
29
+ }
30
+ ]
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emailbutler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdanov Anton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-11 00:00:00.000000000 Z
11
+ date: 2024-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-container
@@ -216,6 +216,7 @@ files:
216
216
  - lib/emailbutler/helpers.rb
217
217
  - lib/emailbutler/mailers/helpers.rb
218
218
  - lib/emailbutler/version.rb
219
+ - lib/emailbutler/webhooks/mappers/resend.rb
219
220
  - lib/emailbutler/webhooks/mappers/sendgrid.rb
220
221
  - lib/emailbutler/webhooks/mappers/smtp2go.rb
221
222
  - lib/emailbutler/webhooks/receiver.rb