Skip to content

Commit

Permalink
atom: bug fix for published/updated for bookmarks
Browse files Browse the repository at this point in the history
fixes #480
  • Loading branch information
snarfed committed Jan 27, 2023
1 parent aa2cd45 commit bb7c631
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion granary/templates/_entry.atom
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
{% if activity.verb in VERBS_WITH_OBJECT and (obj.url or obj.id) %}
<activity:object>{{ obj.url or obj.id }}</activity:object>
{% endif %}
{% set base = activity if activity.verb in VERBS_WITH_OBJECT else obj %}
{% set base = activity if (activity.verb in VERBS_WITH_OBJECT or obj.objectType == 'bookmark') else obj %}
<published>{{ base.published }}</published>
<updated>{{ base.updated or base.published }}</updated>
{% for orig in obj.inReplyTo or activity.context.inReplyTo %}
Expand Down
22 changes: 22 additions & 0 deletions granary/tests/test_atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,28 @@ def test_activity_to_atom_like(self):
'updated': '2013-10-25',
}), ignore_blanks=True)

def test_activity_to_atom_bookmark(self):
got = atom.activity_to_atom({
'url': 'bookmark-url',
'objectType': 'activity',
'verb': 'post',
'object': {
'objectType': 'bookmark',
'targetUrl': 'http://orig',
},
'published': '2012-02-22',
'updated': '2013-10-25',
})
self.assert_multiline_in("""\
<activity:object-type>http://activitystrea.ms/schema/1.0/bookmark</activity:object-type>
""", got, ignore_blanks=True)
self.assert_multiline_in("""\
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
<published>2012-02-22</published>
<updated>2013-10-25</updated>
<link rel="self" type="application/atom+xml" href="bookmark-url" />
""", got, ignore_blanks=True)

def test_activity_to_atom_author_without_properties(self):
"""https://console.cloud.google.com/errors/CMPawqSghuDquwE"""
self.assertIn('<title>foo</title>', atom.activity_to_atom({
Expand Down

0 comments on commit bb7c631

Please sign in to comment.