should_filter ||= receiver.blocking?(status.account) # or it's from someone I blocked
should_filter ||= receiver.blocking?(status.mentions.includes(:account).map(&:account)) # or if it mentions someone I blocked
should_filter ||= (status.account.silenced? && !receiver.following?(status.account)) # of if the account is silenced and I'm not following them
- should_filter ||= (status.private_visibility? && !receiver.following?(status.account)) # or if the mentioned account is not permitted to see the private status
if status.reply? && !status.in_reply_to_account_id.nil? # or it's a reply
should_filter ||= receiver.blocking?(status.in_reply_to_account) # to a user I blocked
end
def permitted?(other_account = nil)
- private_visibility? ? (account.id == other_account&.id || other_account&.following?(account)) : other_account.nil? || !account.blocking?(other_account)
+ if private_visibility?
+ (account.id == other_account&.id || other_account&.following?(account) || mentions.include?(other_account))
+ else
+ other_account.nil? || !account.blocking?(other_account)
+ end
end
def ancestors(account = nil)
where('1 = 1')
elsif !account.nil? && target_account.blocking?(account)
where('1 = 0')
+ elsif !account.nil?
+ joins('LEFT OUTER JOIN mentions ON statuses.id = mentions.status_id')
+ .where('mentions.account_id = ?', account.id)
+ .where('statuses.visibility != ? OR mentions.id IS NOT NULL', Status.visibilities[:private])
else
where.not(visibility: :private)
end
text: content(entry),
spoiler_text: content_warning(entry),
created_at: published(entry),
- reply: thread?(entry)
+ reply: thread?(entry),
+ visibility: visibility_scope(entry)
)
if thread?(entry)
def mentions_from_xml(parent, xml)
processed_account_ids = []
- public_visibility = false
xml.xpath('./xmlns:link[@rel="mentioned"]', xmlns: TagManager::XMLNS).each do |link|
- if link['ostatus:object-type'] == TagManager::TYPES[:collection] && link['href'] == TagManager::COLLECTIONS[:public]
- public_visibility = true
- next
- elsif link['ostatus:object-type'] == TagManager::TYPES[:group]
- next
- end
+ next if [TagManager::TYPES[:group], TagManager::TYPES[:collection]].include? link['ostatus:object-type']
url = Addressable::URI.parse(link['href'])
# So we can skip duplicate mentions
processed_account_ids << mentioned_account.id
end
-
- parent.visibility = public_visibility ? :public : :unlisted
- parent.save!
end
def hashtags_from_xml(parent, xml)
xml.at_xpath('./xmlns:summary', xmlns: TagManager::XMLNS)&.content || ''
end
+ def visibility_scope(xml = @xml)
+ xml.at_xpath('./mastodon:scope', mastodon: TagManager::MTDN_XMLNS)&.content&.to_sym || :public
+ end
+
def published(xml = @xml)
xml.at_xpath('./xmlns:published', xmlns: TagManager::XMLNS).content
end
status.mentions.each do |mention|
mentioned_account = mention.account
- next if status.private_visibility? && (!mentioned_account.following?(status.account) || !mentioned_account.local?)
-
if mentioned_account.local?
NotifyService.new.call(mentioned_account, mention)
else