jellyfish-notification 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/jellyfish_notification/jellyfish_mailer.rb +10 -13
- data/lib/jellyfish_notification/simple_listener.rb +16 -14
- data/lib/jellyfish_notification/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69953c5b2d8d951a37f838374ec9ae5bf9472ffb
|
4
|
+
data.tar.gz: e41a785b08bd66392cce3d2eb47d3f3bf2949264
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9e717b1a375f4ac578e540f0ac9cf8095483ebd161a2d72a7ca10e8e4d1dd05d777ff30bd0e7dcde05b1991d233b47bc76e0a0ae357f1d862ec45028535af33
|
7
|
+
data.tar.gz: b9cf0d187ae6b762754c0d5608d732b4c2da068ae8b5646b75cdf88fd03a8bf31bd7c4bbb95e0e1f970d47100ec0ad09fbcd08c1a424763ce69a5802c031f252
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
Jellyfish Notification
|
2
2
|
=======
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/jellyfish-notification.svg)](http://badge.fury.io/rb/jellyfish-notification)
|
4
|
+
|
3
5
|
A notification system for [Project Jellyfish] (https://github.com/projectjellyfish/api). Can be used to send email notifications to users on project create and approval or order create.
|
4
6
|
|
5
7
|
#### Installation
|
@@ -4,33 +4,30 @@ module JellyfishNotification
|
|
4
4
|
class JellyfishMailer < ActionMailer::Base
|
5
5
|
default from: ENV['JELLYFISH_SMTP_DEFAULT_SENDER']
|
6
6
|
|
7
|
-
def
|
8
|
-
|
9
|
-
@
|
10
|
-
@project_url = projects_url+"/#{@project['id'].to_s}"
|
7
|
+
def publish_project_create_confirmation(project, recipients)
|
8
|
+
@project = project
|
9
|
+
@project_url = (Rails.env != 'test') ? (Rails.application.routes.url_helpers.project_url project) : ('http://localhost:3000/api/v1/projects/' + project.id.to_s)
|
11
10
|
recipients = ENV['JELLYFISH_SMTP_DEFAULT_RECIPIENT'] if recipients.empty?
|
12
11
|
mail(template_path: 'jellyfish_mailer', to: recipients, subject: "Project Create Notification: #{@project['name'].to_s.upcase}") unless ENV['JELLYFISH_SMTP_DEFAULT_SENDER'].nil?
|
13
12
|
end
|
14
13
|
|
15
|
-
def
|
16
|
-
|
17
|
-
@
|
18
|
-
@project_url = projects_url+"/#{@project['id'].to_s}"
|
14
|
+
def publish_project_create_approvers(project, recipients)
|
15
|
+
@project = project
|
16
|
+
@project_url = (Rails.env != 'test') ? (Rails.application.routes.url_helpers.project_url project) : ('http://localhost:3000/api/v1/projects/' + project.id.to_s)
|
19
17
|
recipients = ENV['JELLYFISH_SMTP_DEFAULT_RECIPIENT'] if recipients.empty?
|
20
18
|
mail(template_path: 'jellyfish_mailer', to: recipients, subject: "Project Create Notification: #{@project['name'].to_s.upcase}") unless ENV['JELLYFISH_SMTP_DEFAULT_SENDER'].nil?
|
21
19
|
end
|
22
20
|
|
23
|
-
def publish_project_approval_update(project, recipients
|
24
|
-
# format block causes weirdness, so depending on rails conventions so templates resolve
|
21
|
+
def publish_project_approval_update(project, recipients)
|
25
22
|
@project = project
|
26
|
-
@project_url = project_url
|
23
|
+
@project_url = (Rails.env != 'test') ? (Rails.application.routes.url_helpers.project_url project) : ('http://localhost:3000/api/v1/projects/' + project.id.to_s)
|
27
24
|
recipients = ENV['JELLYFISH_SMTP_DEFAULT_RECIPIENT'] if recipients.empty?
|
28
25
|
mail(template_path: 'jellyfish_mailer', to: recipients, subject: "Project Approval Notification: #{@project.name.to_s.upcase}") unless ENV['JELLYFISH_SMTP_DEFAULT_SENDER'].nil?
|
29
26
|
end
|
30
27
|
|
31
|
-
def publish_order_create(order, recipients
|
28
|
+
def publish_order_create(order, recipients)
|
32
29
|
@order = order
|
33
|
-
@order_url =
|
30
|
+
@order_url = (Rails.env != 'test') ? (Rails.application.routes.url_helpers.order_url order) : ('http://http://localhost:3000/order-history/' + order.id.to_s)
|
34
31
|
recipients = ENV['JELLYFISH_SMTP_DEFAULT_RECIPIENT'] if recipients.empty?
|
35
32
|
mail(template_path: 'jellyfish_mailer', to: recipients, subject: 'Order Create Notification') unless ENV['JELLYFISH_SMTP_DEFAULT_SENDER'].nil?
|
36
33
|
end
|
@@ -1,31 +1,33 @@
|
|
1
1
|
module JellyfishNotification
|
2
2
|
class SimpleListener
|
3
|
-
# IF
|
4
|
-
def publish_project_create(
|
5
|
-
|
6
|
-
|
3
|
+
# IF 'JELLYFISH_ASYNCHRONOUS_DELIVERY' IS true THEN MAIL GETS ADDED TO DELAYED JOBS
|
4
|
+
def publish_project_create(project, current_user)
|
5
|
+
project_approvers = Staff.admin.pluck(:email).join(', ')
|
6
|
+
project_creator = current_user.email
|
7
7
|
if ENV['JELLYFISH_ASYNCHRONOUS_DELIVERY'] == 'true'
|
8
|
-
JellyfishMailer.delay.publish_project_create_confirmation(
|
9
|
-
JellyfishMailer.delay.publish_project_create_approvers(
|
8
|
+
JellyfishMailer.delay.publish_project_create_confirmation(project, project_creator)
|
9
|
+
JellyfishMailer.delay.publish_project_create_approvers(project, project_approvers)
|
10
10
|
else
|
11
|
-
JellyfishMailer.publish_project_create_confirmation(
|
12
|
-
JellyfishMailer.publish_project_create_approvers(
|
11
|
+
JellyfishMailer.publish_project_create_confirmation(project, project_creator).deliver_now
|
12
|
+
JellyfishMailer.publish_project_create_approvers(project, project_approvers).deliver_now
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def publish_project_approval_update(project
|
16
|
+
def publish_project_approval_update(project)
|
17
|
+
project_approvers = Staff.admin.pluck(:email).join(', ')
|
17
18
|
if ENV['JELLYFISH_ASYNCHRONOUS_DELIVERY'] == 'true'
|
18
|
-
JellyfishMailer.delay.publish_project_approval_update(project,
|
19
|
+
JellyfishMailer.delay.publish_project_approval_update(project, project_approvers)
|
19
20
|
else
|
20
|
-
JellyfishMailer.publish_project_approval_update(project,
|
21
|
+
JellyfishMailer.publish_project_approval_update(project, project_approvers).deliver_now
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
|
-
def publish_order_create(order,
|
25
|
+
def publish_order_create(order, current_user)
|
26
|
+
order_creator = current_user.email
|
25
27
|
if ENV['JELLYFISH_ASYNCHRONOUS_DELIVERY'] == 'true'
|
26
|
-
JellyfishMailer.delay.publish_order_create(order,
|
28
|
+
JellyfishMailer.delay.publish_order_create(order, order_creator)
|
27
29
|
else
|
28
|
-
JellyfishMailer.publish_order_create(order,
|
30
|
+
JellyfishMailer.publish_order_create(order, order_creator).deliver_now
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jellyfish-notification
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mafernando
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|