diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb new file mode 100644 index 000000000..19364cd8d --- /dev/null +++ b/app/helpers/notifications_helper.rb @@ -0,0 +1,16 @@ +module NotificationsHelper + def create_system_notification(title, message) + 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! + end + end +end diff --git a/lib/tasks/notifications.rake b/lib/tasks/notifications.rake new file mode 100644 index 000000000..3b688a6df --- /dev/null +++ b/lib/tasks/notifications.rake @@ -0,0 +1,10 @@ +namespace :notifications do + + desc 'Creates new system notification for all active users' + task :new_release => :environment do + include NotificationsHelper + puts 'Creation of system notification for all active users with link to release notes' + create_system_notification('New release', 'http://scinote.net/docs/release-notes/') + end + +end