snarfed / bridgy

📣 Connects your web site to social media. Likes, retweets, mentions, cross-posting, and more...
https://brid.gy
Creative Commons Zero v1.0 Universal
740 stars 52 forks source link

publish chokes on multiple in-reply-tos #117

Closed snarfed closed 10 years ago

snarfed commented 10 years ago

e.g. this markup from https://snarfed.org/2014-04-01_8721 :

likes 
<a class='u-like u-like-of' href='https://twitter.com/github/status/451070440367067136'>Twitter / github: L is for Labels ...</a>,
<a class='u-like u-like-of' href='https://github.com/blog/1815-l-is-for-labels'>GitHub Blog: L is for Labels</a>
<a href='https://www.brid.gy/publish/twitter'></a>

causes this:

Error: 'list' object has no attribute 'get'
Traceback (most recent call last):
  File "/base/data/home/apps/s~brid-gy/3.374840478794920912/publish.py", line 157, in post
    preview = self.source.as_source.preview_create(obj, include_link=True)
  File "/base/data/home/apps/s~brid-gy/3.374840478794920912/activitystreams/twitter.py", line 334, in preview_create
    return self._create(obj, preview=True, include_link=include_link)
  File "/base/data/home/apps/s~brid-gy/3.374840478794920912/activitystreams/twitter.py", line 356, in _create
    base_id, base_url = self.base_object(obj)
  File "/base/data/home/apps/s~brid-gy/3.374840478794920912/activitystreams/twitter.py", line 477, in base_object
    id, url = super(Twitter, self).base_object(obj)
  File "/base/data/home/apps/s~brid-gy/3.374840478794920912/activitystreams/source.py", line 494, in base_object
    id = base_obj.get('id')
AttributeError: 'list' object has no attribute 'get'
snarfed commented 10 years ago

log from https://appengine.google.com/logs?app_id=s~brid-gy&version_id=3.374841083344973558&severity_level_override=1&severity_level=3&tz=US%2FPacific&filter=aglzfmJyaWQtZ3lySgsSDVB1Ymxpc2hlZFBhZ2UiI2h0dHBzOi8vc25hcmZlZC5vcmcvMjAxNC0wNC0wMV84NzIxDAsSB1B1Ymxpc2gYgICAgICAgAoM&filter_type=regex&date_type=now&date=2014-04-01&time=17%3A16%3A39&limit=20&view=Search :

2014-04-01 15:02:38.704
Parsed microformats2: {'rels': {'apple-touch-icon-precomposed': [u'https://snarfed.org/ryan_profile_square_thumb.jpg'], 'tag': ['https://snarfed.org/category/indieweb_like'], 'home': ['https://snarfed.org/', 'https://snarfed.org/'], 'canonical': ['https://snarfed.org/2014-04-01_8721'], 'category': ['https://snarfed.org/category/indieweb_like'], 'generator': ['http://wordpress.org/'], 'author': ['http://snarfed.org/'], 'bookmark': ['https://snarfed.org/2014-04-01_8721'], 'http://webmention.org/': ['https://snarfed.org/w/?webmention=endpoint'], 'shortcut': [u'https://snarfed.org/ryan_profile_square_thumb.jpg'], 'next': ['https://snarfed.org/2014-04-01_8724'], 'stylesheet': ['https://snarfed.org/w/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/nextgen_gallery_display/static/nextgen_gallery_related_images.css?ver=3.8.1', 'https://snarfed.org/w/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/nextgen_gallery_display/static/fontawesome/font-awesome.css?ver=3.8.1', 'https://snarfed.org/w/wp-content/plugins/jetpack/modules/subscriptions/subscriptions.css?ver=3.8.1', 'https://snarfed.org/w/wp-content/plugins/jetpack/modules/widgets/widgets.css?ver=20121003', 'https://snarfed.org/w/wp-content/plugins/jetpack/modules/carousel/jetpack-carousel.css?ver=20120629', 'https://snarfed.org/w/wp-includes/js/mediaelement/mediaelementplayer.min.css?ver=2.13.0', 'https://snarfed.org/w/wp-includes/js/mediaelement/wp-mediaelement.css?ver=3.8.1', 'https://snarfed.org/w/wp-content/themes/snarfed-ryu/style.css?ver=3.8.1', 'https://fonts.googleapis.com/css?family=Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic', 'https://fonts.googleapis.com/css?family=Playfair+Display:400,700,900,400italic,700italic,900italic&subset=latin,latin-ext'], 'prev': ['https://snarfed.org/2014-04-01_8717'], 'openid2.local_id': ['http://www.google.com/profiles/heaven'], 'profile': ['http://gmpg.org/xfn/11'], 'designer': ['http://theme.wordpress.com/'], 'shortlink': ['http://wp.me/s3EDAq-8721'], 'webmention': ['https://snarfed.org/w/?webmention=endpoint'], 'openid2.provider': ['https://www.google.com/accounts/o8/ud?source=profiles'], 'icon': [u'https://snarfed.org/ryan_profile_square_thumb.jpg'], 'me': ['mailto:public@ryanb.org', 'https://twitter.com/schnarfed', 'https://www.facebook.com/snarfed.org', 'https://plus.google.com/+RyanBarrett', 'https://github.com/snarfed'], 'publisher': ['https://plus.google.com/103651231634018158746'], 'pingback': ['https://snarfed.org/w/xmlrpc.php'], 'nofollow': [u'https://snarfed.org/2014-04-01_8721#respond']}, 'items': [{'type': ['h-entry', 'h-as-article'], 'properties': {'like': ['https://twitter.com/github/status/451070440367067136', 'https://github.com/blog/1815-l-is-for-labels'], 'author': [{'type': ['h-card'], 'properties': {'url': ['http://snarfed.org/'], 'photo': ['https://secure.gravatar.com/avatar/947b5f3f323da0ef785b6f02d9c265d6?s=96&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&r=G'], 'name': ['Ryan Barrett']}, 'value': u' Ryan Barrett'}], 'url': ['https://snarfed.org/2014-04-01_8721'], 'like-of': ['https://twitter.com/github/status/451070440367067136', 'https://github.com/blog/1815-l-is-for-labels'], 'content': [{'html': u'<p>likes \n<a class="u-like u-like-of" href="https://twitter.com/github/status/451070440367067136">Twitter / github: L is for Labels \u2026</a>,\n<a class="u-like u-like-of" href="https://github.com/blog/1815-l-is-for-labels">GitHub Blog: L is for Labels</a>\n<a href="https://www.brid.gy/publish/twitter"></a></p>\n', 'value': u'likes \nTwitter / github: L is for Labels \u2026,\nGitHub Blog: L is for Labels\n\n'}], 'published': ['2014-04-01T13:06:51-07:00'], 'name': [u'']}, 'children': [{'type': ['h-card'], 'properties': {'name': [u'Ryan Barrett'], 'locality': [u'San Francisco'], 'url': ['https://snarfed.org/'], 'photo': ['https://snarfed.org/ryan_profile_square_thumb.jpg'], 'region': [u'California'], 'email': ['mailto:public@ryanb.org']}, 'value': u"\n\r\nI'm Ryan Barrett.\r\nI live, work, and play in\r\n San FranciscoCalifornia.\r\nI code, write, and post pictures here.\r\n\n\npublic@ryanb.org\n\n\n\nHome\n\n\n\n\nSearch\n\n\n\n\nArchives\n\n\n\n\nTwitter\n\n\n\n\nFacebook\n\n\n\n\nGoogle+\n\n\n\n\nGitHub\n\n\n\n\nRSS Feed\n\n\n\n"}]}], 'alternates': [{'url': 'https://snarfed.org/feed', 'type': 'application/rss+xml'}, {'url': 'https://snarfed.org/comments/feed', 'type': 'application/rss+xml'}, {'url': 'https://snarfed.org/2014-04-01_8721/feed', 'type': 'application/rss+xml'}]}

D 2014-04-01 15:02:38.771
Converted to ActivityStreams object: {'url': 'https://snarfed.org/2014-04-01_8721', 'object': [{'url': 'https://twitter.com/github/status/451070440367067136'}, {'url': 'https://github.com/blog/1815-l-is-for-labels'}], 'actor': {'url': 'http://snarfed.org/', 'image': {'url': 'https://secure.gravatar.com/avatar/947b5f3f323da0ef785b6f02d9c265d6?s=96&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&r=G'}, 'displayName': 'Ryan Barrett', 'objectType': 'person'}, 'content': u'likes \nTwitter / github: L is for Labels \u2026,\nGitHub Blog: L is for Labels\n\n', 'verb': 'like', 'published': '2014-04-01T13:06:51-07:00', 'objectType': 'activity'}
snarfed commented 10 years ago

fixed by baea84bf504ddb4e42cf2154b4ae6e1033fc15a3