mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 09:42:46 +08:00
Subtype fixes
This commit is contained in:
parent
3f338cafed
commit
cc5aa5eaf5
3 changed files with 9 additions and 32 deletions
|
@ -6,7 +6,7 @@ class BaseNotification < Noticed::Base
|
||||||
|
|
||||||
def self.send_notifications(params, later: false)
|
def self.send_notifications(params, later: false)
|
||||||
recipients_class =
|
recipients_class =
|
||||||
"Recipients::#{NotificationExtends::NOTIFICATIONS_TYPES[params[:type]][:recipients_module]}".constantize
|
"Recipients::#{NotificationExtends::NOTIFICATIONS_TYPES[subtype || params[:type]][:recipients_module]}".constantize
|
||||||
recipients_class.new(params).recipients.each do |recipient|
|
recipients_class.new(params).recipients.each do |recipient|
|
||||||
if later
|
if later
|
||||||
with(params).deliver_later(recipient)
|
with(params).deliver_later(recipient)
|
||||||
|
@ -16,8 +16,10 @@ class BaseNotification < Noticed::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.subtype; end
|
||||||
|
|
||||||
def subtype
|
def subtype
|
||||||
params[:type]
|
self.class.subtype || params[:type]
|
||||||
end
|
end
|
||||||
|
|
||||||
def subject; end
|
def subject; end
|
||||||
|
|
|
@ -1,40 +1,15 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# To deliver this notification:
|
|
||||||
#
|
|
||||||
# GeneralNotification.with(post: @post).deliver_later(current_user)
|
|
||||||
# GeneralNotification.with(post: @post).deliver(current_user)
|
|
||||||
|
|
||||||
class GeneralNotification < BaseNotification
|
class GeneralNotification < BaseNotification
|
||||||
# Add your delivery methods
|
|
||||||
#
|
|
||||||
# deliver_by :email, mailer: "UserMailer"
|
|
||||||
# deliver_by :slack
|
|
||||||
# deliver_by :custom, class: "MyDeliveryMethod"
|
|
||||||
|
|
||||||
# Add required params
|
|
||||||
#
|
|
||||||
# param :post
|
|
||||||
|
|
||||||
# Define helper methods to make rendering easier.
|
|
||||||
#
|
|
||||||
def message
|
def message
|
||||||
# if params[:legacy]
|
|
||||||
params[:message]
|
params[:message]
|
||||||
# else
|
|
||||||
# new logic
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def title
|
def title
|
||||||
# if params[:legacy]
|
|
||||||
params[:title]
|
params[:title]
|
||||||
# else
|
|
||||||
# new logic
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
#
|
|
||||||
# def url
|
def subtype
|
||||||
# post_path(params[:post])
|
params[:type]
|
||||||
# end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ class LowStockNotification < BaseNotification
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def subtype
|
def self.subtype
|
||||||
:item_low_stock_reminder
|
:item_low_stock_reminder
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue