diff --git a/app/models/communication_channel.rb b/app/models/communication_channel.rb index 32c9bc87b50..20b122308ac 100644 --- a/app/models/communication_channel.rb +++ b/app/models/communication_channel.rb @@ -32,7 +32,6 @@ class CommunicationChannel < ActiveRecord::Base before_save :consider_retiring, :assert_path_type, :set_confirmation_code before_save :consider_building_pseudonym before_validation :validate_unique_path - after_create :setup_default_notification_policies after_save :remove_other_paths acts_as_list :scope => :user_id @@ -42,17 +41,6 @@ class CommunicationChannel < ActiveRecord::Base attr_reader :request_password attr_reader :send_confirmation attr_accessor :do_delayed_jobs_immediately - - def setup_default_notification_policies - if self.user.try(:communication_channels).try(:length) == 1 && self.user.try(:notification_policies).try(:empty?) - if @do_delayed_jobs_immediately - NotificationPolicy.defaults_for(self.user) - else - NotificationPolicy.send_later(:defaults_for, self.user) - end - end - end - protected :setup_default_notification_policies def remove_other_paths if @state_was != 'active' && self.active? && self.path_type == 'email' diff --git a/app/models/notification_policy.rb b/app/models/notification_policy.rb index 2cf3f6326ad..cd586aa2d23 100644 --- a/app/models/notification_policy.rb +++ b/app/models/notification_policy.rb @@ -83,18 +83,7 @@ class NotificationPolicy < ActiveRecord::Base puts e.to_s false end - - def self.defaults_for(user) - return unless user && user.email - email_channel = user.email_channel - existing_ids = user.notification_policies.map{|np| np.notification_id} - Notification.transaction do - Notification.all.each do |notification| - user.notification_policies.create(:broadcast => true, :communication_channel => email_channel, :notification => notification, :frequency => notification.default_frequency) unless existing_ids.include?(notification.id) - end - end - end - + def self.refresh_for(user) categories = Notification.dashboard_categories policies = user.notification_policies.to_a