Skip to content

Commit

Permalink
mastodon: prefer media_attachments.remote_url when available
Browse files Browse the repository at this point in the history
...since it may be more long-lived than `url` for remote statuses. fixes snarfed/bridgy#1675
  • Loading branch information
snarfed committed Feb 26, 2024
1 parent 6a3834c commit 0aa5432
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -346,6 +346,7 @@ Changelog
* `mastodon`:
* `get_activities` bug fix: use query params for `/api/v1/notifications` API call, not JSON body.
* Convert HTTP 200 responses with `error` JSON field (eg from Sharkey) to 400/401 exceptions.
* Prefer `media_attachments.remote_url` when available since it may be more long-lived than `url` for remote statuses ([bridgy#1675](https://github.com/snarfed/bridgy/issues/1675)).
* `microformats2`:
* `object_to_json` bug fix: handle singular `inReplyTo`.
* `nostr:`
Expand Down
2 changes: 1 addition & 1 deletion granary/mastodon.py
Expand Up @@ -375,7 +375,7 @@ def status_to_object(self, status):
'objectType': MEDIA_TYPES.get(type),
'displayName': desc,
}
url = media.get('url')
url = media.get('remote_url') or media.get('url')
if type == 'image':
att['image'] = {
'url': url,
Expand Down
3 changes: 2 additions & 1 deletion granary/tests/test_mastodon.py
Expand Up @@ -203,8 +203,9 @@ def tag_uri(name):
}, {
'id': '444',
'type': 'gifv',
'url': 'http://foo.com/video.mp4',
'url': 'http://use/remote/url/instead',
'preview_url': 'http://foo.com/poster.png',
'remote_url': 'http://foo.com/video.mp4',
'description': 'a fun video',
'meta': {
'width': 640,
Expand Down

0 comments on commit 0aa5432

Please sign in to comment.