handle no-replies flag
parent
1636a4e8ae
commit
d6738df083
|
@ -171,6 +171,7 @@ class FeedManager
|
||||||
if status.reply? && !status.in_reply_to_account_id.nil? # Filter out if it's a reply
|
if status.reply? && !status.in_reply_to_account_id.nil? # Filter out if it's a reply
|
||||||
should_filter = !Follow.where(account_id: receiver_id, target_account_id: status.in_reply_to_account_id).exists? # and I'm not following the person it's a reply to
|
should_filter = !Follow.where(account_id: receiver_id, target_account_id: status.in_reply_to_account_id).exists? # and I'm not following the person it's a reply to
|
||||||
should_filter &&= receiver_id != status.in_reply_to_account_id # and it's not a reply to me
|
should_filter &&= receiver_id != status.in_reply_to_account_id # and it's not a reply to me
|
||||||
|
should_filter ||= Status.find(status.in_reply_to_id)&.marked_no_replies? # or the parent has no-replies set
|
||||||
should_filter &&= status.account_id != status.in_reply_to_account_id # and it's not a self-reply
|
should_filter &&= status.account_id != status.in_reply_to_account_id # and it's not a self-reply
|
||||||
return should_filter
|
return should_filter
|
||||||
elsif status.reblog? # Filter out a reblog
|
elsif status.reblog? # Filter out a reblog
|
||||||
|
@ -185,6 +186,7 @@ class FeedManager
|
||||||
|
|
||||||
def filter_from_mentions?(status, receiver_id)
|
def filter_from_mentions?(status, receiver_id)
|
||||||
return true if receiver_id == status.account_id
|
return true if receiver_id == status.account_id
|
||||||
|
return true if status.reply? && !status.in_reply_to_id.nil? && Status.find(status.in_reply_to_id)&.marked_no_replies?
|
||||||
return true if phrase_filtered?(status, receiver_id, :notifications)
|
return true if phrase_filtered?(status, receiver_id, :notifications)
|
||||||
|
|
||||||
# This filter is called from NotifyService, but already after the sender of
|
# This filter is called from NotifyService, but already after the sender of
|
||||||
|
|
|
@ -30,6 +30,9 @@ class StatusFilter
|
||||||
# I don't think this should happen, but just in case...
|
# I don't think this should happen, but just in case...
|
||||||
return filtered_reply if status&.mentions.nil?
|
return filtered_reply if status&.mentions.nil?
|
||||||
|
|
||||||
|
# filter non-op posts replying to something marked no replies
|
||||||
|
return true if reply_to_no_replies?
|
||||||
|
|
||||||
# Grab a list of account IDs mentioned in the status.
|
# Grab a list of account IDs mentioned in the status.
|
||||||
mentioned_account_ids = status.mentions.pluck(:account_id)
|
mentioned_account_ids = status.mentions.pluck(:account_id)
|
||||||
|
|
||||||
|
@ -63,6 +66,14 @@ class StatusFilter
|
||||||
@preloaded_relations[:muting] ? @preloaded_relations[:muting][status.in_reply_to_account_id] : account.muting?(status.in_reply_to_account_id)
|
@preloaded_relations[:muting] ? @preloaded_relations[:muting][status.in_reply_to_account_id] : account.muting?(status.in_reply_to_account_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reply_to_no_replies?
|
||||||
|
status.reply? &&
|
||||||
|
!status.in_reply_to_account_id.nil? &&
|
||||||
|
!status.in_reply_to_id.nil? &&
|
||||||
|
status.account_id != status.in_reply_to_account_id &&
|
||||||
|
Status.find(status.in_reply_to_id)&.marked_no_replies?
|
||||||
|
end
|
||||||
|
|
||||||
def blocking_account?
|
def blocking_account?
|
||||||
@preloaded_relations[:blocking] ? @preloaded_relations[:blocking][status.account_id] : account.blocking?(status.account_id)
|
@preloaded_relations[:blocking] ? @preloaded_relations[:blocking][status.account_id] : account.blocking?(status.account_id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -511,6 +511,10 @@ class Status < ApplicationRecord
|
||||||
'👁'
|
'👁'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def marked_no_replies?
|
||||||
|
/(:ms_dont_at_me:|(don't|do not|no) ((at|@|mention) me)|reply|replies)/.match?(spoiler_text)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def update_status_stat!(attrs)
|
def update_status_stat!(attrs)
|
||||||
|
|
Loading…
Reference in New Issue