jellyfish-notification 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ca67009e7fc8630306f3a9a003a0e42b906f8ca
4
- data.tar.gz: c23de5a583f4808f8250bf2daed3045d20e0ddc2
3
+ metadata.gz: 69953c5b2d8d951a37f838374ec9ae5bf9472ffb
4
+ data.tar.gz: e41a785b08bd66392cce3d2eb47d3f3bf2949264
5
5
  SHA512:
6
- metadata.gz: b9b0d8f1fae0661c8ad5924e50dce15b23513c6e156ad8b1a2474de857af43c495ed6d57ddf68bb2a09f222c29f1777f4d059ed41f872618244e36c41db552d9
7
- data.tar.gz: 71bdc46c0248e93f739af96c06e61e074b9b4467ebc873e6ac25ecc9f93ac2ffa8957f8a1943bc632e58052bc5149b6e3d3e5ffaf40d8ce4cdb8c522c5d2e696
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 publish_project_create_approvers(response, recipients, projects_url)
8
- # format block causes weirdness, so depending on rails conventions so templates resolve
9
- @project = JSON.parse(response.body).to_h
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 publish_project_create_confirmation(response, recipients, projects_url)
16
- # format block causes weirdness, so depending on rails conventions so templates resolve
17
- @project = JSON.parse(response.body).to_h
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, project_url)
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, orders_url)
28
+ def publish_order_create(order, recipients)
32
29
  @order = order
33
- @order_url = orders_url+"/#{@order.id}"
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 ENV['JELLYFISH_ASYNCHRONOUS_DELIVERY'] == 'true') THEN QUEUE WITH DELAYED JOBS ELSE DELIVER NOW
4
- def publish_project_create(response, recipients, projects_url)
5
- project_creator = recipients[:project_creator]
6
- project_approvers = recipients[:project_approvers]
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(response, project_creator, projects_url)
9
- JellyfishMailer.delay.publish_project_create_approvers(response, project_approvers, projects_url)
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(response, project_creator, projects_url).deliver_now
12
- JellyfishMailer.publish_project_create_approvers(response, project_approvers, projects_url).deliver_now
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, recipients, project_url)
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, recipients, project_url)
19
+ JellyfishMailer.delay.publish_project_approval_update(project, project_approvers)
19
20
  else
20
- JellyfishMailer.publish_project_approval_update(project, recipients, project_url).deliver_now
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, recipients, orders_url)
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, recipients, orders_url)
28
+ JellyfishMailer.delay.publish_order_create(order, order_creator)
27
29
  else
28
- JellyfishMailer.publish_order_create(order, recipients, orders_url).deliver_now
30
+ JellyfishMailer.publish_order_create(order, order_creator).deliver_now
29
31
  end
30
32
  end
31
33
  end
@@ -1,3 +1,3 @@
1
1
  module JellyfishNotification
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  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.1
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-09 00:00:00.000000000 Z
11
+ date: 2015-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails