mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-16 14:17:00 +08:00
db3f217bba
[SCI-9512]
27 lines
614 B
Ruby
27 lines
614 B
Ruby
# frozen_string_literal: true
|
|
|
|
module GenerateNotificationModel
|
|
extend ActiveSupport::Concern
|
|
include GlobalActivitiesHelper
|
|
|
|
included do
|
|
after_create :generate_notification
|
|
end
|
|
|
|
def generate_notification_from_activity
|
|
params = { activity_id: id, type: "#{type_of}_activity".to_sym }
|
|
ActivityNotification.send_notifications(params, later: true)
|
|
end
|
|
|
|
protected
|
|
|
|
def notifiable?
|
|
NotificationExtends::NOTIFICATIONS_TYPES.key?("#{type_of}_activity".to_sym)
|
|
end
|
|
|
|
private
|
|
|
|
def generate_notification
|
|
CreateNotificationFromActivityJob.perform_later(self) if notifiable?
|
|
end
|
|
end
|