diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 4ad39cce..722fbe0c 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -4,8 +4,11 @@ class NotificationsController < ApplicationController before_action :authenticate_user! TYPE_MAPPINGS = { - "smile" => "appendable::reaction", - "reaction" => "appendable::reaction" + "answer" => Notification::QuestionAnswered.name, + "comment" => Notification::Commented.name, + "commentsmile" => Notification::CommentSmiled.name, + "relationship" => Notification::StartedFollowing.name, + "smile" => Notification::Smiled.name, }.freeze def index diff --git a/app/models/notification.rb b/app/models/notification.rb index 78a54b5b..f7a19c05 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -13,7 +13,7 @@ class Notification < ApplicationRecord end def for_type(recipient, type, options={}) - self.where(options.merge!(recipient: recipient)).where('LOWER(target_type) = ?', type).order(:created_at).reverse_order + self.where(options.merge!(recipient: recipient)).where(type: type).order(:created_at).reverse_order end def notify(recipient, target) @@ -38,12 +38,12 @@ class Notification < ApplicationRecord private - def make_notification(recipient, target, notification_type) - n = notification_type.new(target: target, - recipient: recipient, - new: true) - n.save! - n - end + def make_notification(recipient, target, notification_type) + n = notification_type.new(target: target, + recipient: recipient, + new: true) + n.save! + n + end end end