2016-09-29 22:51:27 +08:00
|
|
|
module NotificationsHelper
|
|
|
|
def create_system_notification(title, message)
|
2016-10-03 21:12:48 +08:00
|
|
|
notification = Notification.new
|
|
|
|
notification.title = title
|
|
|
|
notification.message = message
|
|
|
|
notification.type_of = :system_message
|
|
|
|
notification.transaction do
|
|
|
|
User.where.not(confirmed_at: nil).find_each do |u|
|
|
|
|
UserNotification
|
|
|
|
.new(user: u, notification: notification, checked: false)
|
|
|
|
.save!
|
|
|
|
end
|
|
|
|
notification.save!
|
2016-09-29 22:51:27 +08:00
|
|
|
end
|
|
|
|
end
|
2016-10-05 16:52:27 +08:00
|
|
|
|
|
|
|
def send_email_notification(user, notification)
|
|
|
|
AppMailer.delay.notification(user, notification)
|
|
|
|
end
|
2016-09-29 22:51:27 +08:00
|
|
|
end
|