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
625216d8
Unverified
Commit
625216d8
authored
2 years ago
by
Claire
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix attachments of edited statuses not being fetched (#21565)
* Fix attachments of edited statuses not being fetched * Fix tests
parent
d587a268
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/services/activitypub/process_status_update_service.rb
+7
-1
7 additions, 1 deletion
app/services/activitypub/process_status_update_service.rb
spec/services/activitypub/process_status_update_service_spec.rb
+3
-3
3 additions, 3 deletions
...ervices/activitypub/process_status_update_service_spec.rb
with
10 additions
and
4 deletions
app/services/activitypub/process_status_update_service.rb
+
7
−
1
View file @
625216d8
...
...
@@ -92,7 +92,13 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
next
if
unsupported_media_type?
(
media_attachment_parser
.
file_content_type
)
||
skip_download?
RedownloadMediaWorker
.
perform_async
(
media_attachment
.
id
)
if
media_attachment
.
remote_url_previously_changed?
||
media_attachment
.
thumbnail_remote_url_previously_changed?
begin
media_attachment
.
download_file!
if
media_attachment
.
remote_url_previously_changed?
media_attachment
.
download_thumbnail!
if
media_attachment
.
thumbnail_remote_url_previously_changed?
media_attachment
.
save
rescue
Mastodon
::
UnexpectedResponseError
,
HTTP
::
TimeoutError
,
HTTP
::
ConnectionError
,
OpenSSL
::
SSL
::
SSLError
RedownloadMediaWorker
.
perform_in
(
rand
(
30
..
600
).
seconds
,
media_attachment
.
id
)
end
rescue
Addressable
::
URI
::
InvalidURIError
=>
e
Rails
.
logger
.
debug
"Invalid URL in attachment:
#{
e
}
"
end
...
...
This diff is collapsed.
Click to expand it.
spec/services/activitypub/process_status_update_service_spec.rb
+
3
−
3
View file @
625216d8
...
...
@@ -331,7 +331,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
context
'originally without media attachments'
do
before
do
allow
(
RedownloadMediaWorker
).
to
re
ceive
(
:perform_async
)
stub_request
(
:get
,
'https://example.com/foo.png'
).
to
_
re
turn
(
body:
attachment_fixture
(
'emojo.png'
)
)
subject
.
call
(
status
,
json
)
end
...
...
@@ -355,8 +355,8 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
expect
(
media_attachment
.
remote_url
).
to
eq
'https://example.com/foo.png'
end
it
'
queues download of media
attachment
s
'
do
expect
(
RedownloadMediaWorker
).
to
have_received
(
:perform_async
)
it
'
fetches the
attachment'
do
expect
(
a_request
(
:get
,
'https://example.com/foo.png'
)).
to
have_been_made
end
it
'records media change in edit'
do
...
...
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