Merge branch 'main' into glitch-soc/merge-upstream

Conflicts:
- `app/services/remove_status_service.rb`:
  Conflict due to glitch-soc having extra code for a proper direct visibility
  timeline, in a part of the code upstream refactored.
  Restored glitch-soc's extra code in the refactored bit.
This commit is contained in:
Claire
2022-05-16 09:42:32 +02:00
163 changed files with 1785 additions and 991 deletions

View File

@@ -3,6 +3,7 @@
class RemoveStatusService < BaseService
include Redisable
include Payloadable
include Lockable
# Delete a status
# @param [Status] status
@@ -17,38 +18,34 @@ class RemoveStatusService < BaseService
@account = status.account
@options = options
RedisLock.acquire(lock_options) do |lock|
if lock.acquired?
@status.discard
with_lock("distribute:#{@status.id}") do
@status.discard
remove_from_self if @account.local?
remove_from_followers
remove_from_lists
remove_from_self if @account.local?
remove_from_followers
remove_from_lists
# There is no reason to send out Undo activities when the
# cause is that the original object has been removed, since
# original object being removed implicitly removes reblogs
# of it. The Delete activity of the original is forwarded
# separately.
remove_from_remote_reach if @account.local? && !@options[:original_removed]
# There is no reason to send out Undo activities when the
# cause is that the original object has been removed, since
# original object being removed implicitly removes reblogs
# of it. The Delete activity of the original is forwarded
# separately.
remove_from_remote_reach if @account.local? && !@options[:original_removed]
# Since reblogs don't mention anyone, don't get reblogged,
# favourited and don't contain their own media attachments
# or hashtags, this can be skipped
unless @status.reblog?
remove_from_mentions
remove_reblogs
remove_from_hashtags
remove_from_public
remove_from_media if @status.with_media?
remove_from_direct if status.direct_visibility?
remove_media
end
@status.destroy! if permanently?
else
raise Mastodon::RaceConditionError
# Since reblogs don't mention anyone, don't get reblogged,
# favourited and don't contain their own media attachments
# or hashtags, this can be skipped
unless @status.reblog?
remove_from_mentions
remove_reblogs
remove_from_hashtags
remove_from_public
remove_from_media if @status.with_media?
remove_from_direct if status.direct_visibility?
remove_media
end
@status.destroy! if permanently?
end
end
@@ -152,8 +149,4 @@ class RemoveStatusService < BaseService
def permanently?
@options[:immediate] || !(@options[:preserve] || @status.reported?)
end
def lock_options
{ redis: redis, key: "distribute:#{@status.id}", autorelease: 5.minutes.seconds }
end
end