mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 01:35:34 +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)
|
||||
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|
|
||||
if later
|
||||
with(params).deliver_later(recipient)
|
||||
|
@ -16,8 +16,10 @@ class BaseNotification < Noticed::Base
|
|||
end
|
||||
end
|
||||
|
||||
def self.subtype; end
|
||||
|
||||
def subtype
|
||||
params[:type]
|
||||
self.class.subtype || params[:type]
|
||||
end
|
||||
|
||||
def subject; end
|
||||
|
|
|
@ -1,40 +1,15 @@
|
|||
# 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
|
||||
# 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
|
||||
# if params[:legacy]
|
||||
params[:message]
|
||||
# else
|
||||
# new logic
|
||||
# end
|
||||
end
|
||||
|
||||
def title
|
||||
# if params[:legacy]
|
||||
params[:title]
|
||||
# else
|
||||
# new logic
|
||||
# end
|
||||
end
|
||||
#
|
||||
# def url
|
||||
# post_path(params[:post])
|
||||
# end
|
||||
|
||||
def subtype
|
||||
params[:type]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ class LowStockNotification < BaseNotification
|
|||
)
|
||||
end
|
||||
|
||||
def subtype
|
||||
def self.subtype
|
||||
:item_low_stock_reminder
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue