Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
ca3bc1b0
Unverified
Commit
ca3bc1b0
authored
4 years ago
by
Eugen Rochko
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Refactor StatusReachFinder to handle followers and relays as well (#16051)
parent
6d6000f6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/lib/status_reach_finder.rb
+24
-1
24 additions, 1 deletion
app/lib/status_reach_finder.rb
app/services/remove_status_service.rb
+5
-29
5 additions, 29 deletions
app/services/remove_status_service.rb
with
29 additions
and
30 deletions
app/lib/status_reach_finder.rb
+
24
−
1
View file @
ca3bc1b0
...
...
@@ -6,11 +6,22 @@ class StatusReachFinder
end
def
inboxes
Account
.
where
(
id:
reached_account_ids
).
inboxes
(
reached_account_inboxes
+
followers_inboxes
+
relay_inboxes
).
uniq
end
private
def
reached_account_inboxes
# When the status is a reblog, there are no interactions with it
# directly, we assume all interactions are with the original one
if
@status
.
reblog?
[]
else
Account
.
where
(
id:
reached_account_ids
).
inboxes
end
end
def
reached_account_ids
[
replied_to_account_id
,
...
...
@@ -49,4 +60,16 @@ class StatusReachFinder
def
replies_account_ids
@status
.
replies
.
pluck
(
:account_id
)
end
def
followers_inboxes
@status
.
account
.
followers
.
inboxes
end
def
relay_inboxes
if
@status
.
public_visibility?
Relay
.
enabled
.
pluck
(
:inbox_url
)
else
[]
end
end
end
This diff is collapsed.
Click to expand it.
app/services/remove_status_service.rb
+
5
−
29
View file @
ca3bc1b0
...
...
@@ -27,10 +27,7 @@ class RemoveStatusService < BaseService
# original object being removed implicitly removes reblogs
# of it. The Delete activity of the original is forwarded
# separately.
if
@account
.
local?
&&
!
@options
[
:original_removed
]
remove_from_remote_followers
remove_from_remote_reach
end
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
...
...
@@ -82,13 +79,10 @@ class RemoveStatusService < BaseService
end
def
remove_from_remote_reach
return
if
@status
.
reblog?
# People who got mentioned in the status, or who
# reblogged it from someone else might not follow
# the author and wouldn't normally receive the
# delete notification - so here, we explicitly
# send it to them
# Followers, relays, people who got mentioned in the status,
# or who reblogged it from someone else might not follow
# the author and wouldn't normally receive the delete
# notification - so here, we explicitly send it to them
status_reach_finder
=
StatusReachFinder
.
new
(
@status
)
...
...
@@ -97,24 +91,6 @@ class RemoveStatusService < BaseService
end
end
def
remove_from_remote_followers
ActivityPub
::
DeliveryWorker
.
push_bulk
(
@account
.
followers
.
inboxes
)
do
|
inbox_url
|
[
signed_activity_json
,
@account
.
id
,
inbox_url
]
end
relay!
if
relayable?
end
def
relayable?
@status
.
public_visibility?
end
def
relay!
ActivityPub
::
DeliveryWorker
.
push_bulk
(
Relay
.
enabled
.
pluck
(
:inbox_url
))
do
|
inbox_url
|
[
signed_activity_json
,
@account
.
id
,
inbox_url
]
end
end
def
signed_activity_json
@signed_activity_json
||=
Oj
.
dump
(
serialize_payload
(
@status
,
@status
.
reblog?
?
ActivityPub
::
UndoAnnounceSerializer
:
ActivityPub
::
DeleteSerializer
,
signer:
@account
))
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment