1
0
Fork 0
forked from gitea/nas

Add support for editing for published statuses (#16697)

* Add support for editing for published statuses

* Fix references to stripped-out code

* Various fixes and improvements

* Further fixes and improvements

* Fix updates being potentially sent to unauthorized recipients

* Various fixes and improvements

* Fix wrong words in test

* Fix notifying accounts that were tagged but were not in the audience

* Fix mistake
This commit is contained in:
Eugen Rochko 2022-01-19 22:37:27 +01:00 committed by GitHub
parent 2d1f082bb6
commit 1060666c58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 1415 additions and 574 deletions

View file

@ -1,8 +1,12 @@
# frozen_string_literal: true
class StatusReachFinder
def initialize(status)
@status = status
# @param [Status] status
# @param [Hash] options
# @option options [Boolean] :unsafe
def initialize(status, options = {})
@status = status
@options = options
end
def inboxes
@ -38,7 +42,7 @@ class StatusReachFinder
end
def replied_to_account_id
@status.in_reply_to_account_id
@status.in_reply_to_account_id if distributable?
end
def reblog_of_account_id
@ -49,21 +53,26 @@ class StatusReachFinder
@status.mentions.pluck(:account_id)
end
# Beware: Reblogs can be created without the author having had access to the status
def reblogs_account_ids
@status.reblogs.pluck(:account_id)
@status.reblogs.pluck(:account_id) if distributable? || unsafe?
end
# Beware: Favourites can be created without the author having had access to the status
def favourites_account_ids
@status.favourites.pluck(:account_id)
@status.favourites.pluck(:account_id) if distributable? || unsafe?
end
# Beware: Replies can be created without the author having had access to the status
def replies_account_ids
@status.replies.pluck(:account_id)
@status.replies.pluck(:account_id) if distributable? || unsafe?
end
def followers_inboxes
if @status.in_reply_to_local_account? && @status.distributable?
if @status.in_reply_to_local_account? && distributable?
@status.account.followers.or(@status.thread.account.followers).inboxes
elsif @status.direct_visibility? || @status.limited_visibility?
[]
else
@status.account.followers.inboxes
end
@ -76,4 +85,12 @@ class StatusReachFinder
[]
end
end
def distributable?
@status.public_visibility? || @status.unlisted_visibility?
end
def unsafe?
@options[:unsafe]
end
end