Appease the dog overlords
This commit is contained in:
parent
1b22872002
commit
08e5764bf3
|
@ -1,9 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class NotificationsController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
|
||||
TYPE_MAPPINGS = {
|
||||
'smile' => 'appendable::reaction',
|
||||
'reaction' => 'appendable::reaction',
|
||||
"smile" => "appendable::reaction",
|
||||
"reaction" => "appendable::reaction"
|
||||
}.freeze
|
||||
|
||||
def index
|
||||
|
@ -24,9 +26,9 @@ class NotificationsController < ApplicationController
|
|||
cursor_params = { last_id: last_id, size: size }.compact
|
||||
|
||||
case type
|
||||
when 'all'
|
||||
when "all"
|
||||
Notification.cursored_for(current_user, **cursor_params)
|
||||
when 'new'
|
||||
when "new"
|
||||
Notification.cursored_for(current_user, new: true, **cursor_params)
|
||||
else
|
||||
Notification.cursored_for_type(current_user, type, **cursor_params)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Appendable::Reaction < Appendable
|
||||
# rubocop:disable Rails/SkipsModelValidations
|
||||
after_create do
|
||||
Notification.notify parent.user, self unless parent.user == user
|
||||
user.increment! :smiled_count
|
||||
|
@ -12,6 +13,7 @@ class Appendable::Reaction < Appendable
|
|||
user.decrement! :smiled_count
|
||||
parent.decrement! :smile_count
|
||||
end
|
||||
# rubocop:enable Rails/SkipsModelValidations
|
||||
|
||||
def notification_type(*_args)
|
||||
Notifications::Smiled
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MoveSmilesToAppendables < ActiveRecord::Migration[6.1]
|
||||
def up
|
||||
execute "INSERT INTO appendables (type, user_id, parent_id, parent_type, content, created_at, updated_at)
|
||||
|
|
Loading…
Reference in New Issue