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
1a1b8170
Unverified
Commit
1a1b8170
authored
6 years ago
by
Eugen Rochko
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix Announce activities of unknown statuses not fetching those statuses (#10065)
Regression from #9998
parent
147b4c2c
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/activitypub/activity.rb
+1
-2
1 addition, 2 deletions
app/lib/activitypub/activity.rb
spec/lib/activitypub/activity/announce_spec.rb
+31
-12
31 additions, 12 deletions
spec/lib/activitypub/activity/announce_spec.rb
with
32 additions
and
14 deletions
app/lib/activitypub/activity.rb
+
1
−
2
View file @
1a1b8170
...
...
@@ -150,8 +150,7 @@ class ActivityPub::Activity
end
end
# If the status is not from the actor, try to fetch it
return
fetch_remote_original_status
if
value_or_id
(
first_of_value
(
@json
[
'attributedTo'
]))
==
@account
.
uri
fetch_remote_original_status
end
def
fetch_remote_original_status
...
...
This diff is collapsed.
Click to expand it.
spec/lib/activitypub/activity/announce_spec.rb
+
31
−
12
View file @
1a1b8170
require
'rails_helper'
RSpec
.
describe
ActivityPub
::
Activity
::
Announce
do
let
(
:sender
)
{
Fabricate
(
:account
,
followers_url:
'http://example.com/followers'
)
}
let
(
:sender
)
{
Fabricate
(
:account
,
followers_url:
'http://example.com/followers'
,
uri:
'https://example.com/actor'
)
}
let
(
:recipient
)
{
Fabricate
(
:account
)
}
let
(
:status
)
{
Fabricate
(
:status
,
account:
recipient
)
}
...
...
@@ -10,21 +10,29 @@ RSpec.describe ActivityPub::Activity::Announce do
'@context'
:
'https://www.w3.org/ns/activitystreams'
,
id:
'foo'
,
type:
'Announce'
,
actor:
ActivityPub
::
TagManager
.
instance
.
uri_for
(
sender
)
,
actor:
'https://example.com/actor'
,
object:
object_json
,
}.
with_indifferent_access
end
subject
{
described_class
.
new
(
json
,
sender
)
}
before
do
sender
.
update
(
uri:
ActivityPub
::
TagManager
.
instance
.
uri_for
(
sender
))
let
(
:unknown_object_json
)
do
{
'@context'
:
'https://www.w3.org/ns/activitystreams'
,
id:
'https://example.com/actor/hello-world'
,
type:
'Note'
,
attributedTo:
'https://example.com/actor'
,
content:
'Hello world'
,
to:
'http://example.com/followers'
,
}
end
subject
{
described_class
.
new
(
json
,
sender
)
}
describe
'#perform'
do
context
'when sender is followed by a local account'
do
before
do
Fabricate
(
:account
).
follow!
(
sender
)
stub_request
(
:get
,
'https://example.com/actor/hello-world'
).
to_return
(
body:
Oj
.
dump
(
unknown_object_json
))
subject
.
perform
end
...
...
@@ -38,10 +46,21 @@ RSpec.describe ActivityPub::Activity::Announce do
end
end
context
'an unknown status'
do
let
(
:object_json
)
{
'https://example.com/actor/hello-world'
}
it
'creates a reblog by sender of status'
do
reblog
=
sender
.
statuses
.
first
expect
(
reblog
).
to_not
be_nil
expect
(
reblog
.
reblog
.
text
).
to
eq
'Hello world'
end
end
context
'self-boost of a previously unknown status with missing attributedTo'
do
let
(
:object_json
)
do
{
id:
[
ActivityPub
::
TagManager
.
instance
.
uri_for
(
sender
),
'#bar'
].
join
,
id:
'https://example.com/actor#bar'
,
type:
'Note'
,
content:
'Lorem ipsum'
,
to:
'http://example.com/followers'
,
...
...
@@ -56,10 +75,10 @@ RSpec.describe ActivityPub::Activity::Announce do
context
'self-boost of a previously unknown status with correct attributedTo'
do
let
(
:object_json
)
do
{
id:
[
ActivityPub
::
TagManager
.
instance
.
uri_for
(
sender
),
'#bar'
].
join
,
id:
'https://example.com/actor#bar'
,
type:
'Note'
,
content:
'Lorem ipsum'
,
attributedTo:
ActivityPub
::
TagManager
.
instance
.
uri_for
(
sender
)
,
attributedTo:
'https://example.com/actor'
,
to:
'http://example.com/followers'
,
}
end
...
...
@@ -98,7 +117,7 @@ RSpec.describe ActivityPub::Activity::Announce do
let
(
:object_json
)
do
{
id:
[
ActivityPub
::
TagManager
.
instance
.
uri_for
(
sender
),
'#bar'
].
join
,
id:
'https://example.com/actor#bar'
,
type:
'Note'
,
content:
'Lorem ipsum'
,
to:
'http://example.com/followers'
,
...
...
@@ -117,7 +136,7 @@ RSpec.describe ActivityPub::Activity::Announce do
let
(
:object_json
)
do
{
id:
[
ActivityPub
::
TagManager
.
instance
.
uri_for
(
sender
),
'#bar'
].
join
,
id:
'https://example.com/actor#bar'
,
type:
'Note'
,
content:
'Lorem ipsum'
,
to:
'http://example.com/followers'
,
...
...
@@ -137,7 +156,7 @@ RSpec.describe ActivityPub::Activity::Announce do
let
(
:object_json
)
do
{
id:
[
ActivityPub
::
TagManager
.
instance
.
uri_for
(
sender
),
'#bar'
].
join
,
id:
'https://example.com/actor#bar'
,
type:
'Note'
,
content:
'Lorem ipsum'
,
to:
'http://example.com/followers'
,
...
...
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