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
0dc57ab6
Unverified
Commit
0dc57ab6
authored
3 years ago
by
Eugen Rochko
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix status updates not being forwarded like deletes through ActivityPub (#17648)
Fix #17521
parent
48caeb9d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/lib/activitypub/activity/delete.rb
+3
-37
3 additions, 37 deletions
app/lib/activitypub/activity/delete.rb
app/lib/activitypub/activity/update.rb
+8
-3
8 additions, 3 deletions
app/lib/activitypub/activity/update.rb
app/lib/activitypub/forwarder.rb
+65
-0
65 additions, 0 deletions
app/lib/activitypub/forwarder.rb
with
76 additions
and
40 deletions
app/lib/activitypub/activity/delete.rb
+
3
−
37
View file @
0dc57ab6
...
...
@@ -37,50 +37,16 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity
return
if
@status
.
nil?
forward
!
if
@json
[
'signature'
].
present?
&&
@status
.
distribut
able?
forward
er
.
forward!
if
forwarder
.
forward
able?
delete_now!
end
end
def
rebloggers_ids
return
@rebloggers_ids
if
defined?
(
@rebloggers_ids
)
@rebloggers_ids
=
@status
.
reblogs
.
includes
(
:account
).
references
(
:account
).
merge
(
Account
.
local
).
pluck
(
:account_id
)
end
def
inboxes_for_reblogs
Account
.
where
(
id:
::
Follow
.
where
(
target_account_id:
rebloggers_ids
).
select
(
:account_id
)).
inboxes
end
def
replied_to_status
return
@replied_to_status
if
defined?
(
@replied_to_status
)
@replied_to_status
=
@status
.
thread
end
def
reply_to_local?
!
replied_to_status
.
nil?
&&
replied_to_status
.
account
.
local?
end
def
inboxes_for_reply
replied_to_status
.
account
.
followers
.
inboxes
end
def
forward!
inboxes
=
inboxes_for_reblogs
inboxes
+=
inboxes_for_reply
if
reply_to_local?
inboxes
-=
[
@account
.
preferred_inbox_url
]
sender_id
=
reply_to_local?
?
replied_to_status
.
account_id
:
rebloggers_ids
.
first
ActivityPub
::
LowPriorityDeliveryWorker
.
push_bulk
(
inboxes
.
uniq
)
do
|
inbox_url
|
[
payload
,
sender_id
,
inbox_url
]
end
def
forwarder
@forwarder
||=
ActivityPub
::
Forwarder
.
new
(
@account
,
@json
,
@status
)
end
def
delete_now!
RemoveStatusService
.
new
.
call
(
@status
,
redraft:
false
)
end
def
payload
@payload
||=
Oj
.
dump
(
@json
)
end
end
This diff is collapsed.
Click to expand it.
app/lib/activitypub/activity/update.rb
+
8
−
3
View file @
0dc57ab6
...
...
@@ -22,10 +22,15 @@ class ActivityPub::Activity::Update < ActivityPub::Activity
def
update_status
return
reject_payload!
if
invalid_origin?
(
@object
[
'id'
])
status
=
Status
.
find_by
(
uri:
object_uri
,
account_id:
@account
.
id
)
@
status
=
Status
.
find_by
(
uri:
object_uri
,
account_id:
@account
.
id
)
return
if
status
.
nil?
return
if
@
status
.
nil?
ActivityPub
::
ProcessStatusUpdateService
.
new
.
call
(
status
,
@object
)
forwarder
.
forward!
if
forwarder
.
forwardable?
ActivityPub
::
ProcessStatusUpdateService
.
new
.
call
(
@status
,
@object
)
end
def
forwarder
@forwarder
||=
ActivityPub
::
Forwarder
.
new
(
@account
,
@json
,
@status
)
end
end
This diff is collapsed.
Click to expand it.
app/lib/activitypub/forwarder.rb
0 → 100644
+
65
−
0
View file @
0dc57ab6
# frozen_string_literal: true
class
ActivityPub::Forwarder
def
initialize
(
account
,
original_json
,
status
)
@json
=
original_json
@account
=
account
@status
=
status
end
def
forwardable?
@json
[
'signature'
].
present?
&&
@status
.
distributable?
end
def
forward!
ActivityPub
::
LowPriorityDeliveryWorker
.
push_bulk
(
inboxes
)
do
|
inbox_url
|
[
payload
,
signature_account_id
,
inbox_url
]
end
end
private
def
payload
@payload
||=
Oj
.
dump
(
@json
)
end
def
reblogged_by_account_ids
@reblogged_by_account_ids
||=
@status
.
reblogs
.
includes
(
:account
).
references
(
:account
).
merge
(
Account
.
local
).
pluck
(
:account_id
)
end
def
signature_account_id
@signature_account_id
||=
begin
if
in_reply_to_local?
in_reply_to
.
account_id
else
reblogged_by_account_ids
.
first
end
end
end
def
inboxes
@inboxes
||=
begin
arr
=
inboxes_for_followers_of_reblogged_by_accounts
arr
+=
inboxes_for_followers_of_replied_to_account
if
in_reply_to_local?
arr
-=
[
@account
.
preferred_inbox_url
]
arr
.
uniq!
arr
end
end
def
inboxes_for_followers_of_reblogged_by_accounts
Account
.
where
(
id:
::
Follow
.
where
(
target_account_id:
reblogged_by_account_ids
).
select
(
:account_id
)).
inboxes
end
def
inboxes_for_followers_of_replied_to_account
in_reply_to
.
account
.
followers
.
inboxes
end
def
in_reply_to
@status
.
thread
end
def
in_reply_to_local?
@status
.
thread
&
.
account
&
.
local?
end
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