add Mention tag for Mastodon replies

fixes #34. thanks @swentel!
pull/37/head
Ryan Barrett 2018-10-16 08:26:55 -07:00 zatwierdzone przez Ryan Barrett
rodzic a0f6f669b7
commit 25d2724700
2 zmienionych plików z 19 dodań i 1 usunięć

Wyświetl plik

@ -254,6 +254,21 @@ def postprocess_as2(activity, target=None, key=None):
'Only using the first: %s' % in_reply_tos[0])
activity['inReplyTo'] = in_reply_to[0]
# Mastodon evidently requires a Mention tag for replies to generate a
# notification to the original post's author. not required for likes,
# reposts, etc. details:
# https://github.com/snarfed/bridgy-fed/issues/34
to = target.get('actor') or target.get('attributedTo')
if to:
if isinstance(to, dict):
to = to.get('url') or to.get('id')
if to:
activity.setdefault('tag', []).append({
'type': 'Mention',
'href': to,
})
# activity objects (for Like, Announce, etc): prefer id over url
obj = activity.get('object', {})
if obj:

Wyświetl plik

@ -175,6 +175,10 @@ class WebmentionTest(testutil.TestCase):
'preferredUsername': 'orig',
'name': 'Ms. ☕ Baz',
}],
'tag': [{
'type': 'Mention',
'href': 'http://orig/author',
}],
},
}
self.as2_update = copy.deepcopy(self.as2_create)
@ -503,4 +507,3 @@ class WebmentionTest(testutil.TestCase):
self.assertIn('Target post http://orig/url has no Atom link', got.body)
self.assertIsNone(Response.get_by_id('http://a/reply http://orig/post'))