From 2a0011441ce4bb16737cd665257a1b1df4723fa0 Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Tue, 17 Nov 2015 08:55:55 -0800 Subject: [PATCH] facebook create: if person tag name has no displayName, default to "User [ID]" for snarfed/bridgy#538 --- granary/facebook.py | 3 ++- granary/test/test_facebook.py | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/granary/facebook.py b/granary/facebook.py index 6164745d..df3a4b05 100644 --- a/granary/facebook.py +++ b/granary/facebook.py @@ -559,7 +559,8 @@ def _create(self, obj, preview=None, include_link=False): preview_content += '

' % image_url if people: preview_content += '

with %s' % ', '.join( - '%s' % (tag.get('url'), tag.get('displayName')) + '%s' % ( + 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: diff --git a/granary/test/test_facebook.py b/granary/test/test_facebook.py index 4929050b..0322a703 100644 --- a/granary/test/test_facebook.py +++ b/granary/test/test_facebook.py @@ -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', }], } @@ -1941,7 +1940,7 @@ def test_create_with_photo_and_person_tags(self): self.assertEquals( '



with ' 'Foo, ' - 'Bar', + 'User 345', preview.content) # test create