mailgun_catcher 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +29 -0
- data/Rakefile +7 -0
- data/app/controllers/mailgun_catcher/application_controller.rb +5 -0
- data/app/controllers/mailgun_catcher/webhooks_controller.rb +8 -0
- data/config/routes.rb +3 -0
- data/lib/mailgun_catcher.rb +7 -0
- data/lib/mailgun_catcher/engine.rb +5 -0
- data/lib/mailgun_catcher/event.rb +54 -0
- data/lib/mailgun_catcher/event_error.rb +22 -0
- data/lib/mailgun_catcher/version.rb +3 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9907b6b8c0abdb7cb2eb83aa636ac8d7db55451ddcd9bd9cb5909eb4df45a4c8
|
4
|
+
data.tar.gz: e3b384f6cd31c87033acc56732b499feafb9d843042449822a0f14243294a5e1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2550f9117b2824d2cab974d555af4e3da78fa5eebc9d0b919fd5d0ae27ba55c57f3399a2482e98ce4df57215ea2c509396dcd04dc3352e5c850e2282c736514d
|
7
|
+
data.tar.gz: 579807f3bebd8c627c0746cb150f0a765fe4795466dc90dfe2b23ff8a74c7543a11dfc0a2bc1f29873eaeb4f4e78ac62c8a1a504fa78a4ced00ac3e2cad5d1bb
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2019 Stjepan Hadjić
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# MailgunCatcher
|
2
|
+
Catch mailgun events and report to bugsnag
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'mailgun_catcher'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
```bash
|
13
|
+
$ bundle
|
14
|
+
```
|
15
|
+
|
16
|
+
Add to routes:
|
17
|
+
```ruby
|
18
|
+
mount MailgunCatcher::Engine, at: "/mailgun_catcher"
|
19
|
+
```
|
20
|
+
|
21
|
+
Configire webhook on mailgun:
|
22
|
+
![](http://take.ms/HZRmm)
|
23
|
+
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
Contribution directions go here.
|
27
|
+
|
28
|
+
## License
|
29
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/config/routes.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
module MailgunCatcher
|
2
|
+
class Event
|
3
|
+
attr_reader :params
|
4
|
+
|
5
|
+
def initialize(params)
|
6
|
+
@params = params.to_unsafe_h
|
7
|
+
end
|
8
|
+
|
9
|
+
def notify_bugsnag
|
10
|
+
Bugsnag.notify(EventError.new(self))
|
11
|
+
end
|
12
|
+
|
13
|
+
def error_message
|
14
|
+
"[#{severity}] [#{reason}] #{recipient}: #{delivery_status}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def event_data
|
18
|
+
params.fetch('event-data', {})
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def delivery_status
|
24
|
+
return delivery_status_message if delivery_status_message.present?
|
25
|
+
return delivery_status_description if delivery_status_description.present?
|
26
|
+
|
27
|
+
'missing delivery status message'
|
28
|
+
end
|
29
|
+
|
30
|
+
def delivery_status_message
|
31
|
+
event_data.fetch('delivery-status', {}).fetch('message', '')
|
32
|
+
end
|
33
|
+
|
34
|
+
def delivery_status_description
|
35
|
+
event_data.fetch('delivery-status', {}).fetch('description', '')
|
36
|
+
end
|
37
|
+
|
38
|
+
def recipient
|
39
|
+
event_data.fetch('recipient', 'no recipient')
|
40
|
+
end
|
41
|
+
|
42
|
+
def event
|
43
|
+
event_data.fetch('event', 'unkown event')
|
44
|
+
end
|
45
|
+
|
46
|
+
def severity
|
47
|
+
event_data.fetch('severity', '')
|
48
|
+
end
|
49
|
+
|
50
|
+
def reason
|
51
|
+
event_data.fetch('reason', '')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module MailgunCatcher
|
2
|
+
class EventError < StandardError
|
3
|
+
attr_reader :event
|
4
|
+
|
5
|
+
def initialize(event)
|
6
|
+
@event = event
|
7
|
+
super(event.error_message)
|
8
|
+
end
|
9
|
+
|
10
|
+
def bugsnag_meta_data
|
11
|
+
{ event_details: event.event_data }
|
12
|
+
end
|
13
|
+
|
14
|
+
def bugsnag_context
|
15
|
+
'mailgun'
|
16
|
+
end
|
17
|
+
|
18
|
+
def bugsnag_grouping_hash
|
19
|
+
event.error_message
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mailgun_catcher
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stjepan Hadjić
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bugsnag
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 5.2.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 5.2.2
|
41
|
+
description: Engine for maingun hooks
|
42
|
+
email:
|
43
|
+
- d4be4st@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- MIT-LICENSE
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- app/controllers/mailgun_catcher/application_controller.rb
|
52
|
+
- app/controllers/mailgun_catcher/webhooks_controller.rb
|
53
|
+
- config/routes.rb
|
54
|
+
- lib/mailgun_catcher.rb
|
55
|
+
- lib/mailgun_catcher/engine.rb
|
56
|
+
- lib/mailgun_catcher/event.rb
|
57
|
+
- lib/mailgun_catcher/event_error.rb
|
58
|
+
- lib/mailgun_catcher/version.rb
|
59
|
+
homepage: https://github.com/infinum/rails-infinum-maingun_catcher
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata:
|
63
|
+
allowed_push_host: https://rubygems.org
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.7.6
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Engine for maingun hooks
|
84
|
+
test_files: []
|