diff --git a/app/models/message.rb b/app/models/message.rb index f121c0872d6..839f722bd21 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -51,7 +51,6 @@ class Message < ActiveRecord::Base before_save :infer_defaults before_save :move_dashboard_messages before_save :move_messages_for_deleted_users - before_save :set_asset_context_code # Validations validates :body, length: {maximum: maximum_text_length}, allow_nil: true, allow_blank: true @@ -144,8 +143,6 @@ class Message < ActiveRecord::Base end # Named scopes - scope :for_asset_context_codes, lambda { |context_codes| where(:asset_context_code => context_codes) } - scope :for, lambda { |context| where(:context_type => context.class.base_class.to_s, :context_id => context) } scope :after, lambda { |date| where("messages.created_at>?", date) } @@ -592,25 +589,6 @@ class Message < ActiveRecord::Base raise end - class RemoteConfigurationError < StandardError; end - # Public: Determine the remote configuration for notification_service - # - # Returns string remote configuration (eventually a hash). - def remote_configuration - case path_type - when "email" - return "email.amazonaws.com" - when "push" - return "push.com" - when "twitter" - return 'twitter' - when "sms" - return if to =~ /^\+[0-9]+$/ ? "Twilio.com" : "email.amazonaws.com" - else - raise RemoteConfigurationError, "No matching path types for notification service" - end - end - # Public: Determines the message body for a notification endpoint # # Returns target notification message body @@ -765,15 +743,6 @@ class Message < ActiveRecord::Base end end - # Public: Before save, set the proper asset_context_code for the model. - # - # Returns an asset_context_code string or nil. - def set_asset_context_code - self.asset_context_code = "#{context_type.underscore}_#{context_id}" - rescue - nil - end - # Public: Return the message as JSON filtered to selected fields and # flattened appropriately. # diff --git a/config/initializers/dropped_columns.rb b/config/initializers/dropped_columns.rb index 3a465c1830b..21a36bb9dc1 100644 --- a/config/initializers/dropped_columns.rb +++ b/config/initializers/dropped_columns.rb @@ -118,7 +118,7 @@ ActiveRecord::Base::DROPPED_COLUMNS = { 'learning_outcome_results' => %w{comments}.freeze, 'learning_outcome_question_results' => %w{context_code context_id context_type}.freeze, 'lti_resource_placements' => %w(resource_handler_id).freeze, - 'messages' => %w(cc bcc notification_category).freeze, + 'messages' => %w(cc bcc notification_category asset_context_code).freeze, 'moderated_grading_provisional_grades' => %w(position).freeze, 'notification_policies' => %w(user_id broadcast).freeze, 'page_views' => %w(contributed).freeze, diff --git a/db/migrate/20170725164505_drop_asset_context_code_from_messages.rb b/db/migrate/20170725164505_drop_asset_context_code_from_messages.rb new file mode 100644 index 00000000000..c0433ff4d36 --- /dev/null +++ b/db/migrate/20170725164505_drop_asset_context_code_from_messages.rb @@ -0,0 +1,7 @@ +class DropAssetContextCodeFromMessages < ActiveRecord::Migration[5.0] + tag :postdeploy + + def change + remove_column :messages, :asset_context_code, :string, limit: 255 + end +end diff --git a/lib/notification_message_creator.rb b/lib/notification_message_creator.rb index d79f6d85221..b36f877bf67 100644 --- a/lib/notification_message_creator.rb +++ b/lib/notification_message_creator.rb @@ -183,7 +183,6 @@ class NotificationMessageCreator def dispatch_dashboard_messages(messages) messages.each do |message| - message.set_asset_context_code message.infer_defaults message.create_stream_items end