notifun 1.6

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.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +5 -0
  6. data/Gemfile.lock +45 -0
  7. data/README.md +16 -0
  8. data/app/assets/stylesheets/notifun.sass +62 -0
  9. data/app/controllers/notifun/message_templates_controller.rb +31 -0
  10. data/app/controllers/notifun/messages_controller.rb +15 -0
  11. data/app/controllers/notifun/preferences_controller.rb +26 -0
  12. data/app/mailers/notifun/message_mailer.rb +49 -0
  13. data/app/models/notifun/message.rb +7 -0
  14. data/app/models/notifun/message_template.rb +98 -0
  15. data/app/models/notifun/preference.rb +13 -0
  16. data/app/views/notifun/message_templates/edit.html.haml +53 -0
  17. data/app/views/notifun/message_templates/index.html.haml +29 -0
  18. data/app/views/notifun/messages/index.haml +47 -0
  19. data/app/views/notifun/messages/show.haml +47 -0
  20. data/app/views/notifun/preferences/index.haml +45 -0
  21. data/config/routes.rb +16 -0
  22. data/lib/generators/notifun/install_generator.rb +50 -0
  23. data/lib/generators/notifun/templates/migration.rb +48 -0
  24. data/lib/generators/notifun/templates/notifun.rb +39 -0
  25. data/lib/generators/notifun/templates/notifun_add_push_title.rb +8 -0
  26. data/lib/generators/notifun/templates/notifun_templates.json +29 -0
  27. data/lib/notifun.rb +27 -0
  28. data/lib/notifun/configuration.rb +19 -0
  29. data/lib/notifun/engine.rb +5 -0
  30. data/lib/notifun/notification.rb +166 -0
  31. data/lib/notifun/notifiers/cloud_five_notifier.rb +32 -0
  32. data/lib/notifun/notifiers/email_notifier.rb +11 -0
  33. data/lib/notifun/notifiers/empty_notifier.rb +2 -0
  34. data/lib/notifun/notifiers/notifier.rb +17 -0
  35. data/lib/notifun/notifiers/parent_notifier.rb +12 -0
  36. data/lib/notifun/notifiers/twilio_notifier.rb +28 -0
  37. data/lib/notifun/railtie.rb +48 -0
  38. data/lib/notifun/version.rb +3 -0
  39. data/notifun.gemspec +26 -0
  40. data/spec/notifun_spec.rb +108 -0
  41. data/spec/spec_helper.rb +88 -0
  42. metadata +156 -0
@@ -0,0 +1,29 @@
1
+ %h1 Message Templates
2
+
3
+ %table.notifun-table
4
+ %thead
5
+ %tr
6
+ %th
7
+ %th Sent via
8
+ %th
9
+
10
+ %tbody
11
+ - @message_templates.where(category: nil).each do |message_template|
12
+ %tr
13
+ %td= message_template.description
14
+ %td= message_template.sent_via
15
+ - if message_template.editable
16
+ %td= link_to "Edit", edit_notifun_message_template_path(message_template)
17
+ - else
18
+ %td
19
+ - @message_templates.order(:category).pluck(:category).uniq.compact.each do |category|
20
+ %tr
21
+ %td.notifun-category.notifun-center{colspan: 3}= category.capitalize
22
+ - @message_templates.order(:description).where(category: category).each do |message_template|
23
+ %tr
24
+ %td= message_template.description
25
+ %td= message_template.sent_via
26
+ - if message_template.editable
27
+ %td= link_to "Edit", edit_notifun_message_template_path(message_template)
28
+ - else
29
+ %td
@@ -0,0 +1,47 @@
1
+ %h1 Messages
2
+
3
+ %table.table
4
+ %thead
5
+ %tr
6
+ %th User
7
+ %th Recipient
8
+ %th Sent via
9
+ %th Message Template
10
+ %th Success
11
+ %th Sent At
12
+ %th
13
+
14
+ %tbody
15
+ - @messages.each do |message|
16
+ - user = User.where(uuid: message.uuid).first
17
+ %tr
18
+ - if user.try(:display_name)
19
+ %td= user.display_name
20
+ - else
21
+ %td= message.uuid
22
+ %td= message.recipient
23
+ %td= message.notification_method
24
+ - if message.message_template
25
+ %td= link_to message.message_template_key.humanize, edit_notifun_message_template_path(message.message_template)
26
+ - else
27
+ %td= message.message_template_key.humanize
28
+ %td= message.success ? "Yes" : "No"
29
+ %td= message.created_at.in_time_zone(Notifun.configuration.time_zone).strftime("%D %l:%M %Z")
30
+ %td= link_to "View", message
31
+
32
+ .notifun-center
33
+ - if @page == 1
34
+ %span ← Previous
35
+ - else
36
+ = link_to '← Previous', { page: @page - 1 }
37
+
38
+ - (1..@pages).each do |p|
39
+ - if p == @page
40
+ %em= @page
41
+ - else
42
+ = link_to p, { page: p }
43
+
44
+ - if @page == @pages
45
+ %span Next →
46
+ - else
47
+ = link_to 'Next →', { page: @page + 1 }
@@ -0,0 +1,47 @@
1
+ %h1 Message Details
2
+
3
+ .notifun-detail
4
+ .notifun-detail-title UUID
5
+ .notifun-detail-value= @message.uuid
6
+
7
+ .notifun-detail
8
+ .notifun-detail-title Recipient
9
+ .notifun-detail-value= @message.recipient
10
+
11
+ .notifun-detail
12
+ .notifun-detail-title Sent Via
13
+ .notifun-detail-value= @message.notification_method
14
+
15
+ .notifun-detail
16
+ .notifun-detail-title Template
17
+ .notifun-detail-value
18
+ - if @message.message_template.editable
19
+ = link_to @message.message_template_key.humanize, edit_notifun_message_template_path(@message.message_template)
20
+ - else
21
+ = @message.message_template_key.humanize
22
+
23
+ .notifun-detail
24
+ .notifun-detail-title Sent At
25
+ .notifun-detail-value= @message.created_at.in_time_zone(Notifun.configuration.time_zone).strftime("%D %l:%M %Z")
26
+
27
+ .notifun-detail
28
+ .notifun-detail-title Success
29
+ .notifun-detail-value= @message.success ? "Yes" : "No"
30
+
31
+ - if @message.error_message.present?
32
+ .notifun-detail
33
+ .notifun-detail-title Error Message
34
+ .notifun-detail-value= @message.error_message
35
+
36
+ - if @message.data.present?
37
+ .notifun-detail
38
+ .notifun-detail-title Data
39
+ .notifun-detail-value= @message.data
40
+
41
+ .notifun-detail
42
+ .notifun-detail-title Title
43
+ .notifun-detail-value= @message.message_title || "N/A"
44
+
45
+ .notifun-detail
46
+ .notifun-detail-title Text
47
+ .notifun-detail-value= @message.message_text
@@ -0,0 +1,45 @@
1
+ %h1 Notification Preferences
2
+
3
+ = form_tag save_notifun_preferences_path, class: "notifun-form" do
4
+ - @models.each do |model|
5
+ - index = 0
6
+ %h2 #{model.class.name} Preferences
7
+ %table.notifun-table
8
+ %thead
9
+ %tr
10
+ %th
11
+ - @notification_methods.each do |notification_method|
12
+ %th.notifun-center= notification_method.capitalize
13
+ %tbody
14
+ - message_templates = Notifun::MessageTemplate.where("models @> Array[?]::varchar[]", model.class.name).where("category IS NOT NULL")
15
+ - message_templates.pluck(:category).uniq.each do |category|
16
+ - prefix = "preferences[#{index}]"
17
+ - index += 1
18
+ - preference = Notifun::Preference.where(preferable: model, category: category).first_or_initialize
19
+ = hidden_field_tag "#{prefix}[preferable_type]", model.class.name
20
+ = hidden_field_tag "#{prefix}[preferable_id]", model.id
21
+ = hidden_field_tag "#{prefix}[preference_type]", "category"
22
+ = hidden_field_tag "#{prefix}[category]", category
23
+ %tr
24
+ %td.notifun-category #{category.capitalize} Category
25
+ - @notification_methods.each do |notification_method|
26
+ = hidden_field_tag "#{prefix}[#{notification_method}]", "0"
27
+ %td.notifun-center= check_box_tag "#{prefix}[#{notification_method}]", "1", preference.send(notification_method)
28
+ - message_templates.where(category: category).each do |message_template|
29
+ - prefix = "preferences[#{index}]"
30
+ - index += 1
31
+ - preference = Notifun::Preference.where(preferable: model, message_template_key: message_template.key).first_or_initialize
32
+ = hidden_field_tag "#{prefix}[preferable_type]", model.class.name
33
+ = hidden_field_tag "#{prefix}[preferable_id]", model.id
34
+ = hidden_field_tag "#{prefix}[preference_type]", "message_template_key"
35
+ = hidden_field_tag "#{prefix}[message_template_key]", message_template.key
36
+ %tr
37
+ %td.notifun-indent= message_template.description
38
+ - @notification_methods.each do |notification_method|
39
+ = hidden_field_tag "#{prefix}[#{notification_method}]", "0"
40
+ - checked = preference.persisted? ? preference.send(notification_method) : message_template.notification_methods.include?(notification_method)
41
+ - if message_template.possible_notification_methods.include?(notification_method)
42
+ %td.notifun-center= check_box_tag "#{prefix}[#{notification_method}]", "1", checked
43
+ - else
44
+ %td.notifun-center
45
+ = submit_tag "Save Preferences"
@@ -0,0 +1,16 @@
1
+ # notifun/config/routes.rb
2
+ Rails.application.routes.draw do
3
+ namespace :notifun do
4
+ resources :message_templates, param: :key do
5
+ member do
6
+ get :preview
7
+ end
8
+ end
9
+ resources :messages, only: [:index, :show]
10
+ resources :preferences, only: [:index] do
11
+ collection do
12
+ post :save
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,50 @@
1
+ require 'rails/generators/migration'
2
+ require 'rails/generators/active_record'
3
+ require_relative '../../../app/models/notifun/message_template'
4
+
5
+ class Notifun::InstallGenerator < Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+ source_root File.expand_path("../templates", __FILE__)
8
+
9
+ def copy_notifun_migration
10
+ if !ActiveRecord::Base.connection.table_exists?('notifun_message_templates')
11
+ migration_template "migration.rb", "db/migrate/notifun_create_tables.rb"
12
+ else
13
+ puts "Skipping db/migrate/notifun_create_tables.rb"
14
+ Notifun::MessageTemplate.reset_column_information
15
+ if !Notifun::MessageTemplate.column_names.include?("push_title")
16
+ migration_template "notifun_add_push_title.rb", "db/migrate/notifun_add_push_title.rb"
17
+ end
18
+ end
19
+ end
20
+
21
+ def copy_config_file
22
+ if File.exists?("config/initializers/notifun.rb")
23
+ puts "Skipping config/initializers/notifun.rb"
24
+ else
25
+ copy_file "notifun.rb", "config/initializers/notifun.rb"
26
+ end
27
+ end
28
+
29
+ def copy_json_file
30
+ if File.exists?("config/notifun_templates.json")
31
+ puts "Skipping config/notifun_templates.json"
32
+ else
33
+ copy_file "notifun_templates.json", "config/notifun_templates.json"
34
+ end
35
+ end
36
+
37
+ def rails5?
38
+ Rails.version.start_with? '5'
39
+ end
40
+
41
+ def migration_version
42
+ if rails5?
43
+ "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
44
+ end
45
+ end
46
+
47
+ def self.next_migration_number(dirname)
48
+ ActiveRecord::Generators::Base.next_migration_number(dirname)
49
+ end
50
+ end
@@ -0,0 +1,48 @@
1
+ class NotifunCreateTables < ActiveRecord::Migration<%= migration_version %>
2
+ def change
3
+ create_table :notifun_message_templates do |t|
4
+ t.string :key
5
+ t.string :models, array: true, default: [], null: false
6
+ t.text :description
7
+ t.string :category
8
+ t.string :default_notification_methods, array: true, default: [], null: false
9
+ t.string :backup_notification_methods, array: true, default: [], null: false
10
+ t.jsonb :merge_fields, null: false, default: {}
11
+ t.text :push_title
12
+ t.text :push_body
13
+ t.text :text_body
14
+ t.string :email_subject
15
+ t.text :email_html
16
+ t.text :email_text
17
+ t.boolean :preferences, default: false, null: false
18
+ t.boolean :editable, default: true, null: false
19
+
20
+ t.timestamps
21
+ end
22
+
23
+ create_table :notifun_messages do |t|
24
+ t.string :message_template_key
25
+ t.string :uuid
26
+ t.string :recipient
27
+ t.string :notification_method
28
+ t.text :message_title
29
+ t.text :message_text
30
+ t.jsonb :data, null: false, default: {}
31
+ t.boolean :success, default: false, null: false
32
+ t.text :error_message
33
+
34
+ t.timestamps
35
+ end
36
+
37
+ create_table :notifun_preferences do |t|
38
+ t.references :preferable, polymorphic: true
39
+ t.string :message_template_key
40
+ t.string :category
41
+ t.boolean :email, default: false, null: false
42
+ t.boolean :push, default: false, null: false
43
+ t.boolean :text, default: false, null: false
44
+
45
+ t.timestamps
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,39 @@
1
+ Notifun.configure do |config|
2
+ # Configure which types of notifications can be sent
3
+ # "email", "push", "text"
4
+ config.notification_methods = ["email"]
5
+
6
+ # Configure the parent class responsible to send e-mails.
7
+ config.parent_mailer = 'ApplicationMailer'
8
+
9
+ # Configure how to send push notifications
10
+ # "CloudFive", "Empty"
11
+ # config.push_notifier = "CloudFive"
12
+ # config.push_config = { api_key: ENV["CLOUD_FIVE_API_KEY"] }
13
+
14
+ # Configure how to send text notifications
15
+ # "Twilio", "Empty"
16
+ # config.text_notifier = "Twilio"
17
+ # config.text_config = { account_sid: ENV["TWILIO_ACCOUNT_SID"], auth_token: ENV["TWILIO_AUTH_TOKEN"], from: "+14159341234" }
18
+
19
+ # Configure how to edit html fields
20
+ # "froala", timymce", "none"
21
+ # config.wysiwyg = "timymce"
22
+
23
+ # Configure parent class for Notifun controllers for admin actions like editing message templates
24
+ config.admin_parent_controller = 'ApplicationController'
25
+
26
+ # Configure parent class for Notifun controllers for user actions like editing preferences
27
+ config.user_parent_controller = 'ApplicationController'
28
+
29
+ # Configure controller helper method to use to get the model
30
+ # notifun should use for the currently logged in person for the preferences page
31
+ # should correspond to the 'models' attribute on message template
32
+ # this must be set for preferences to work
33
+ # can return an array of models
34
+ # config.controller_method = "current_user"
35
+
36
+ # If you have the premailer gem installed and you want to use it to automatically
37
+ # convert your html to plain text, set this to true
38
+ config.premailer_html_to_text = false
39
+ end
@@ -0,0 +1,8 @@
1
+ class NotifunAddPushTitle < ActiveRecord::Migration<%= migration_version %>
2
+ def change
3
+ add_column :notifun_message_templates, :push_title, :text
4
+ add_column :notifun_messages, :message_title, :text
5
+ add_column :notifun_messages, :error_message, :text
6
+ add_column :notifun_messages, :data, :jsonb, null: false, default: {}
7
+ end
8
+ end
@@ -0,0 +1,29 @@
1
+ // {
2
+ // "message_template_key" : {
3
+ // "models" : ["User"], // used for preferences, must match models returned by config.controller_method
4
+ // "description" : "Description Text.", // seen by admin for editing and users for preferences
5
+ // "category" : "reminders", // categories for admin organization and user preferences
6
+ // "editable" : false, // indicates whether admin should be able to change the text via the web
7
+ // // methods not in default or backup can be chosen by user preferences if the related text is present
8
+ // // if users have edited their preferences, those will always take precedence over these defaults
9
+ // "default_notification_methods" : ["push"], // tries to send to all of these methods
10
+ // "backup_notification_methods" : ["email"], // if all default methods fail, will try all of backup until one succeeds
11
+ // "preferences" : false, // whether users should be allowed to change preferences or not
12
+ // // display of fields that can be used to show real data; this should match what you pass into Notifun::Notification.notify
13
+ // "merge_fields" : {
14
+ // "full_name" : {
15
+ // "description" : "Full Name of first user",
16
+ // "preview" : "William Riker"
17
+ // },
18
+ // "application_name" : {
19
+ // "description" : "Name of application",
20
+ // "preview" : "Awesome App Name"
21
+ // }
22
+ // },
23
+ // "push_body" : "Hello, {full_name}. Welcome to {application_name}.",
24
+ // "email_subject" : "Welcome to {application_name}.",
25
+ // "email_html" : "<h3>Hello, {full_name},</h3><p>Welcome to {application_name}.</p>",
26
+ // "email_text" : "Hello, {full_name}, Welcome to {application_name}.",
27
+ // "text_body" : "Hello, {full_name}, Welcome to {application_name}."
28
+ // }
29
+ // }
@@ -0,0 +1,27 @@
1
+ require 'notifun/version'
2
+ require 'notifun/configuration'
3
+ require 'notifun/engine'
4
+ require 'notifun/notifiers/notifier'
5
+ require 'notifun/notification'
6
+
7
+ module Notifun
8
+ require 'notifun/railtie' if defined?(Rails)
9
+
10
+ class << self
11
+ attr_accessor :configuration
12
+ end
13
+
14
+ module NotificationMethods
15
+ EMAIL = 'email'
16
+ PUSH = 'push'
17
+ TEXT = 'text'
18
+ end
19
+
20
+ def self.configuration
21
+ @configuration ||= Configuration.new
22
+ end
23
+
24
+ def self.configure
25
+ yield(configuration)
26
+ end
27
+ end
@@ -0,0 +1,19 @@
1
+ class Notifun::Configuration
2
+ attr_accessor :notification_methods, :parent_mailer, :push_notifier, :push_config, :text_notifier, :text_config,
3
+ :wysiwyg, :admin_parent_controller, :user_parent_controller, :controller_method, :time_zone, :premailer_html_to_text
4
+
5
+ def initialize
6
+ @notification_methods = []
7
+ @parent_mailer = 'ActionMailer::Base'
8
+ @push_notifier = "Empty"
9
+ @push_config = {}
10
+ @text_notifier = "Empty"
11
+ @text_config = {}
12
+ @wysiwyg = "none"
13
+ @admin_parent_controller = "ActionController::Base"
14
+ @user_parent_controller = "ActionController::Base"
15
+ @controller_method = "current_user"
16
+ @time_zone = "Etc/UTC"
17
+ @premailer_html_to_text = false
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ class Notifun::Engine < Rails::Engine
2
+ initializer 'notifun.engine', :group => :all do |app|
3
+ app.config.assets.paths << root.join('assets', 'stylesheets')
4
+ end
5
+ end
@@ -0,0 +1,166 @@
1
+ class Notifun::Notification
2
+ # model passed in must have following methods:
3
+ # notifun_uuid or uuid: unique identifier
4
+ # notifun_email or email: email to send to
5
+ # notifun_notify_via or notify_via(method) returns if it should send message using one of the message types: ["email", "push", "text"]
6
+ def self.notify(models, key, merge_hash={}, options={})
7
+ message_template = Notifun::MessageTemplate.find_by_key(key)
8
+ raise "Unable to find message_template with key #{key}" if message_template.nil?
9
+ models = [models].flatten
10
+ status = true
11
+ models.each do |model|
12
+ primary_sent = false
13
+ backup_sent = false
14
+ preference = Notifun::Preference.where(preferable: model).where(message_template_key: key).first
15
+ if message_template.category.present?
16
+ preference ||= Notifun::Preference.where(preferable: model).where(category: message_template.category).first
17
+ end
18
+ if preference
19
+ sent = false
20
+ preference.notification_methods.each do |notification_method|
21
+ next if options[:notification_methods] && !options[:notification_methods].include?(notification_method)
22
+ sent = self.send("send_via_#{notification_method}", message_template, model, merge_hash, options)
23
+ end
24
+
25
+ return sent
26
+ else
27
+ message_template.default_notification_methods.each do |notification_method|
28
+ next if options[:notification_methods] && !options[:notification_methods].include?(notification_method)
29
+ notify_via = model.try(:notifun_notify_via, notification_method)
30
+ notify_via = model.notify_via(notification_method) if notify_via.nil?
31
+ if notify_via
32
+ if self.send("send_via_#{notification_method}", message_template, model, merge_hash, options)
33
+ primary_sent = true
34
+ end
35
+ end
36
+ end
37
+ if !primary_sent
38
+ message_template.backup_notification_methods.each do |notification_method|
39
+ next if options[:notification_methods] && !options[:notification_methods].include?(notification_method)
40
+ notify_via = model.try(:notifun_notify_via, notification_method)
41
+ notify_via = model.notify_via(notification_method) if notify_via.nil?
42
+ if notify_via
43
+ if self.send("send_via_#{notification_method}", message_template, model, merge_hash, options)
44
+ backup_sent = true
45
+ break
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ if status == true
52
+ status = primary_sent || backup_sent
53
+ end
54
+ end
55
+ end
56
+
57
+ return status
58
+ end
59
+
60
+ def self.send_via_text(message_template, model, merge_hash, options)
61
+ if options[:message].present?
62
+ text = options[:message]
63
+ else
64
+ text = message_template.merged_text_body(merge_hash)
65
+ end
66
+ phone = model.try(:notifun_phone).presence || model.try(:phone).presence
67
+ if phone
68
+ text_notifier = Notifun::Notifier.text_notifier.new
69
+ text_notifier.notify!(text, phone, options)
70
+ success = text_notifier.success
71
+ error_message = text_notifier.error_message
72
+ else
73
+ success = false
74
+ error_message = "No phone number."
75
+ end
76
+ uuid = model.try(:notifun_uuid).presence || model.try(:uuid).presence
77
+
78
+ Notifun::Message.create({
79
+ message_template_key: message_template.key,
80
+ uuid: uuid,
81
+ recipient: phone,
82
+ notification_method: "text",
83
+ message_text: text,
84
+ success: success,
85
+ error_message: error_message
86
+ })
87
+
88
+ return success
89
+ end
90
+
91
+ def self.send_via_push(message_template, model, merge_hash, options)
92
+ if options[:message].present?
93
+ text = options[:message]
94
+ else
95
+ text = message_template.merged_push_body(merge_hash)
96
+ end
97
+ if options[:title].present?
98
+ title = options[:title]
99
+ else
100
+ title = message_template.merged_push_title(merge_hash)
101
+ end
102
+ uuid = model.try(:notifun_uuid).presence || model.try(:uuid).presence
103
+ if uuid
104
+ push_notifier = Notifun::Notifier.push_notifier.new
105
+ push_notifier.notify!(text, title, uuid, options)
106
+ success = push_notifier.success
107
+ error_message = push_notifier.error_message
108
+ else
109
+ success = false
110
+ error_message = "No uuid."
111
+ end
112
+ data = options[:push_data].presence || {}
113
+ Notifun::Message.create({
114
+ message_template_key: message_template.key,
115
+ uuid: uuid,
116
+ recipient: uuid,
117
+ notification_method: "push",
118
+ message_text: text,
119
+ success: success,
120
+ message_title: title,
121
+ data: data,
122
+ error_message: error_message
123
+ })
124
+
125
+ return success
126
+ end
127
+
128
+ def self.send_via_email(message_template, model, merge_hash, options)
129
+ if options[:subject].present?
130
+ subject = options[:subject]
131
+ else
132
+ subject = message_template.merged_email_subject(merge_hash)
133
+ end
134
+ if options[:message].present?
135
+ text = html = options[:message]
136
+ else
137
+ text = message_template.merged_email_text(merge_hash)
138
+ html = message_template.merged_email_html(merge_hash)
139
+ end
140
+ email = model.try(:notifun_email).presence || model.try(:email).presence
141
+ if email
142
+ email_notifier = Notifun::Notifier.email_notifier.new
143
+ email_notifier.notify!(email, subject, html, text, message_template, options)
144
+ success = email_notifier.success
145
+ error_message = email_notifier.error_message
146
+ else
147
+ success = false
148
+ error_message = "No email."
149
+ end
150
+
151
+ uuid = model.try(:notifun_uuid).presence || model.try(:uuid).presence
152
+
153
+ Notifun::Message.create({
154
+ message_template_key: message_template.key,
155
+ uuid: uuid,
156
+ recipient: email,
157
+ notification_method: "email",
158
+ message_text: html,
159
+ success: success,
160
+ message_title: subject,
161
+ error_message: error_message
162
+ })
163
+
164
+ return success
165
+ end
166
+ end