mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-12 16:14:58 +08:00
Merge pull request #6808 from artoscinote/ma_SCI_9863
Always save notifications to database, but filter them [SCI-9869]
This commit is contained in:
commit
543ac1a404
3 changed files with 10 additions and 2 deletions
|
@ -22,6 +22,7 @@ class UserNotificationsController < ApplicationController
|
||||||
|
|
||||||
def load_notifications
|
def load_notifications
|
||||||
current_user.notifications
|
current_user.notifications
|
||||||
|
.in_app
|
||||||
.order(created_at: :desc)
|
.order(created_at: :desc)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Notification < ApplicationRecord
|
class Notification < ApplicationRecord
|
||||||
|
|
||||||
include Noticed::Model
|
include Noticed::Model
|
||||||
|
|
||||||
belongs_to :recipient, polymorphic: true
|
belongs_to :recipient, polymorphic: true
|
||||||
|
|
||||||
|
scope :in_app, -> { where.not("notifications.params->'hide_in_app' = 'true'") }
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def can_send_to_user?(_user)
|
def can_send_to_user?(_user)
|
||||||
|
|
|
@ -35,7 +35,12 @@ class BaseNotification < Noticed::Base
|
||||||
private
|
private
|
||||||
|
|
||||||
def database_notification?
|
def database_notification?
|
||||||
recipient.notifications_settings.dig(notification_subgroup.to_s, 'in_app')
|
# always save all notifications,
|
||||||
|
# but flag if they should display in app or not
|
||||||
|
|
||||||
|
params[:hide_in_app] = recipient.notifications_settings.dig(notification_subgroup.to_s, 'in_app') != true
|
||||||
|
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def email_notification?
|
def email_notification?
|
||||||
|
|
Loading…
Add table
Reference in a new issue