mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-18 23:49:42 +00:00
Refactor notification filtering behavior definition (#29567)
This commit is contained in:
parent
27fd084cb5
commit
b43eaa4517
|
@ -29,18 +29,40 @@ class Notification < ApplicationRecord
|
||||||
'Poll' => :poll,
|
'Poll' => :poll,
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
TYPES = %i(
|
PROPERTIES = {
|
||||||
mention
|
mention: {
|
||||||
status
|
filterable: true,
|
||||||
reblog
|
}.freeze,
|
||||||
follow
|
status: {
|
||||||
follow_request
|
filterable: false,
|
||||||
favourite
|
}.freeze,
|
||||||
poll
|
reblog: {
|
||||||
update
|
filterable: true,
|
||||||
admin.sign_up
|
}.freeze,
|
||||||
admin.report
|
follow: {
|
||||||
).freeze
|
filterable: true,
|
||||||
|
}.freeze,
|
||||||
|
follow_request: {
|
||||||
|
filterable: true,
|
||||||
|
}.freeze,
|
||||||
|
favourite: {
|
||||||
|
filterable: true,
|
||||||
|
}.freeze,
|
||||||
|
poll: {
|
||||||
|
filterable: false,
|
||||||
|
}.freeze,
|
||||||
|
update: {
|
||||||
|
filterable: false,
|
||||||
|
}.freeze,
|
||||||
|
'admin.sign_up': {
|
||||||
|
filterable: false,
|
||||||
|
}.freeze,
|
||||||
|
'admin.report': {
|
||||||
|
filterable: false,
|
||||||
|
}.freeze,
|
||||||
|
}.freeze
|
||||||
|
|
||||||
|
TYPES = PROPERTIES.keys.freeze
|
||||||
|
|
||||||
TARGET_STATUS_INCLUDES_BY_TYPE = {
|
TARGET_STATUS_INCLUDES_BY_TYPE = {
|
||||||
status: :status,
|
status: :status,
|
||||||
|
|
|
@ -83,7 +83,7 @@ class NotifyService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter?
|
def filter?
|
||||||
return false if NON_FILTERABLE_TYPES.include?(@notification.type)
|
return false unless Notification::PROPERTIES[@notification.type][:filterable]
|
||||||
return false if override_for_sender?
|
return false if override_for_sender?
|
||||||
|
|
||||||
from_limited? ||
|
from_limited? ||
|
||||||
|
|
Loading…
Reference in a new issue