Skip to content

Commit

Permalink
facebook create: if person tag name has no displayName, default to "U…
Browse files Browse the repository at this point in the history
…ser [ID]"

for snarfed/bridgy#538
  • Loading branch information
snarfed committed Nov 17, 2015
1 parent 2f01979 commit 2a00114
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion granary/facebook.py
Expand Up @@ -559,7 +559,8 @@ def _create(self, obj, preview=None, include_link=False):
preview_content += '<br /><br /><img src="%s" />' % image_url
if people:
preview_content += '<br /><br /><em>with %s</em>' % ', '.join(
'<a href="%s">%s</a>' % (tag.get('url'), tag.get('displayName'))
'<a href="%s">%s</a>' % (
tag.get('url'), tag.get('displayName') or 'User %s' % tag['id'])
for tag in people)
msg_data = {'message': content.encode('utf-8')}
if appengine_config.DEBUG:
Expand Down
3 changes: 1 addition & 2 deletions granary/test/test_facebook.py
Expand Up @@ -1931,7 +1931,6 @@ def test_create_with_photo_and_person_tags(self):
'url': 'https://www.facebook.com/234',
}, {
'objectType': 'person',
'displayName': 'Bar',
'url': 'https://www.facebook.com/345',
}],
}
Expand All @@ -1941,7 +1940,7 @@ def test_create_with_photo_and_person_tags(self):
self.assertEquals(
'<br /><br /><img src="http://my/picture" /><br /><br /><em>with '
'<a href="https://www.facebook.com/234">Foo</a>, '
'<a href="https://www.facebook.com/345">Bar</a></em>',
'<a href="https://www.facebook.com/345">User 345</a></em>',
preview.content)

# test create
Expand Down

0 comments on commit 2a00114

Please sign in to comment.