mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-18 07:52:23 +01:00
Merge branch 'dev' into host
This commit is contained in:
commit
8f210bb713
@ -257,14 +257,16 @@ class Subscription < ActiveRecord::Base
|
||||
|
||||
def notify_subscription_extended(free_days)
|
||||
meta_data = {}
|
||||
meta_data[:free_days] = true if free_days == true
|
||||
notification = Notification.new(meta_data: meta_data)
|
||||
notification.send_notification(type: :notify_member_subscription_extended, attached_object: self).to(user).deliver_later
|
||||
meta_data[:free_days] = true if free_days
|
||||
NotificationCenter.call type: :notify_member_subscription_extended,
|
||||
receiver: user,
|
||||
attached_object: self,
|
||||
meta_data: meta_data
|
||||
|
||||
User.admins.each do |admin|
|
||||
notification = Notification.new(meta_data: meta_data)
|
||||
notification.send_notification(type: :notify_admin_subscription_extended, attached_object: self).to(admin).deliver_later
|
||||
end
|
||||
NotificationCenter.call type: :notify_admin_subscription_extended,
|
||||
receiver: User.admins,
|
||||
attached_object: self,
|
||||
meta_data: meta_data
|
||||
end
|
||||
|
||||
def set_expiration_date
|
||||
|
@ -336,10 +336,10 @@ class User < ActiveRecord::Base
|
||||
ex_group = Group.find(changes[:group_id].first)
|
||||
meta_data = { ex_group_name: ex_group.name }
|
||||
|
||||
User.admins.each do |admin|
|
||||
notification = Notification.new(meta_data: meta_data)
|
||||
notification.send_notification(type: :notify_admin_user_group_changed, attached_object: self).to(admin).deliver_later
|
||||
end
|
||||
NotificationCenter.call type: :notify_admin_user_group_changed,
|
||||
receiver: User.admins,
|
||||
attached_object: self,
|
||||
meta_data: meta_data
|
||||
|
||||
NotificationCenter.call type: :notify_user_user_group_changed,
|
||||
receiver: self,
|
||||
|
@ -1,14 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# send notification to one or several receiver with a type, an attached object and an optional meta data
|
||||
class NotificationCenter
|
||||
# send notification to one or several receiver with a type and attached object
|
||||
def self.call(type: nil, receiver: nil, attached_object: nil)
|
||||
def self.call(type: nil, receiver: nil, attached_object: nil, meta_data: {})
|
||||
if receiver.respond_to?(:each)
|
||||
receiver.each do |user|
|
||||
Notification.new.send_notification(type: type, attached_object: attached_object)
|
||||
Notification.new(meta_data: meta_data)
|
||||
.send_notification(type: type, attached_object: attached_object)
|
||||
.to(user)
|
||||
.deliver_later
|
||||
end
|
||||
else
|
||||
Notification.new.send_notification(type: type, attached_object: attached_object)
|
||||
Notification.new(meta_data: meta_data)
|
||||
.send_notification(type: type, attached_object: attached_object)
|
||||
.to(receiver)
|
||||
.deliver_later
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user