diff --git a/app/models/notification.rb b/app/models/notification.rb index d0a4f3919..1009b9dfe 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -2,14 +2,10 @@ class Notification < ApplicationRecord has_many :user_notifications, inverse_of: :notification, dependent: :destroy - has_many :users, through: :user_notifications - belongs_to :generator_user, class_name: 'User', optional: true include Noticed::Model belongs_to :recipient, polymorphic: true - enum type_of: Extends::NOTIFICATIONS_TYPES - private def can_send_to_user?(_user) diff --git a/config/initializers/extends.rb b/config/initializers/extends.rb index 7d1523c28..41e511b68 100644 --- a/config/initializers/extends.rb +++ b/config/initializers/extends.rb @@ -14,13 +14,6 @@ class Extends # Extends enum types. Should not be freezed, as modules might append to this. # !!!Check all addons for the correct order!!! - # DEPRECATED 'system_message' in (SCI-2952, kept b/c of integer enums) - NOTIFICATIONS_TYPES = { assignment: 0, - recent_changes: 1, - system_message: 2, # DEPRECATED - deliver: 5, - deliver_error: 7 } - TASKS_STATES = { uncompleted: 0, completed: 1 } diff --git a/db/migrate/20231011103114_migrate_notification_to_noticed.rb b/db/migrate/20231011103114_migrate_notification_to_noticed.rb index 843aebfef..888d3d259 100644 --- a/db/migrate/20231011103114_migrate_notification_to_noticed.rb +++ b/db/migrate/20231011103114_migrate_notification_to_noticed.rb @@ -9,10 +9,10 @@ class MigrateNotificationToNoticed < ActiveRecord::Migration[7.0] add_column :notifications, :recipient_type, :string type_mapping = { - 'assignment' => 'ActivityNotification', - 'recent_changes' => 'GeneralNotification', - 'deliver' => 'DeliveryNotification', - 'deliver_error' => 'DeliveryNotification' + 0 => 'ActivityNotification', + 1 => 'GeneralNotification', + 5 => 'DeliveryNotification', + 7 => 'DeliveryNotification' } UserNotification.includes(:notification).find_each do |user_notification| @@ -26,8 +26,7 @@ class MigrateNotificationToNoticed < ActiveRecord::Migration[7.0] legacy: true } - params[:error] = notification.type_of == 'deliver_error' if new_type == 'DeliveryNotification' - + params[:error] = notification.type_of == 7 if new_type == 'DeliveryNotification' notification.update( params: params, type: new_type,