Permalink
Browse files

facebook publish: RIP comments/likes. :(

fixes #350...in the sense that it doesn't fix it at all. facebook api, you win this round.

more background in http://stackoverflow.com/questions/28337331/facebook-graph-api-find-graph-object-from-post-url
  • Loading branch information...
snarfed committed Feb 15, 2015
1 parent 65a8c83 commit 0e44fe28c1df5026b2b237d2c094a0a0ed9c8c00
Showing with 46 additions and 6 deletions.
  1. +9 −0 publish.py
  2. +37 −6 publish_test.py
View
@@ -277,6 +277,15 @@ def attempt_single_item(self, item):
if not self.authorize():
return as_source.creation_result(abort=True)
# RIP Facebook comments/likes. https://github.com/snarfed/bridgy/issues/350
if (isinstance(self.source, FacebookPage) and
(obj_type == 'comment' or obj.get('verb') == 'like')):
return as_source.creation_result(
abort=True,
error_plain='Facebook comments and likes are no longer supported. :(',
error_html='<a href="https://github.com/snarfed/bridgy/issues/350">'
'Facebook comments and likes are no longer supported.</a> :(')
if self.PREVIEW:
result = self.source.as_source.preview_create(
obj, include_link=not omit_link)
View
@@ -14,6 +14,7 @@
import appengine_config
from activitystreams import source as as_source
import facebook
from models import Publish, PublishedPage
import publish
import testutil
@@ -71,20 +72,22 @@ def expect_requests_get(self, url, body='', backlink=None, **kwargs):
resp = super(PublishTest, self).expect_requests_get(url, body, **kwargs)
return resp
def assert_success(self, expected, preview=False, **kwargs):
def assert_response(self, expected, status=None, preview=False, **kwargs):
resp = self.get_response(preview=preview, **kwargs)
self.assertEquals(200, resp.status_int)
self.assertEquals(status, resp.status_int)
if preview:
self.assertIn(expected, resp.body.decode('utf-8'),
'%r\n\n=== vs ===\n\n%r' % (expected, resp.body))
else:
self.assertIn(expected, json.loads(resp.body)['content'])
self.assertIn(expected, json.loads(resp.body)[
'content' if status == 200 else 'error'])
return resp
def assert_success(self, expected, **kwargs):
return self.assert_response(expected, status=200, **kwargs)
def assert_error(self, expected, status=400, **kwargs):
resp = self.get_response(**kwargs)
self.assertEquals(status, resp.status_int)
self.assertIn(expected, json.loads(resp.body)['error'])
return self.assert_response(expected, status=status, **kwargs)
def test_webmention_success(self):
self.expect_requests_get('http://foo.com/bar', self.post_html % 'foo')
@@ -868,3 +871,31 @@ def test_missing_backlink(self):
self.post_html % 'foo')
self.mox.ReplayAll()
self.assert_error("Couldn't find link to http://localhost/publish/fake")
def test_facebook_comment_and_like_disabled(self):
self.source = facebook.FacebookPage(id='789', features=['publish'],
domains=['mr.x'])
self.source.put()
# self.oauth_state['source_key'] = key.urlsafe()
self.expect_requests_get('http://mr.x/like', """
<article class="h-entry">
<a class="u-like-of" href="http://facebook.com/789/posts/456">liked this</a>
<a href="http://localhost/publish/facebook"></a>
</article>""")
self.expect_requests_get('http://mr.x/comment', """
<article class="h-entry">
<a class="u-in-reply-to" href="http://facebook.com/789/posts/456">reply</a>
<a href="http://localhost/publish/facebook"></a>
</article>""")
self.mox.ReplayAll()
self.assert_error('Facebook comments and likes are no longer supported',
source='http://mr.x/like',
target='http://brid.gy/publish/facebook')
self.assertEquals('failed', Publish.query().get().status)
self.assert_error('Facebook comments and likes are no longer supported',
source='http://mr.x/comment',
target='http://brid.gy/publish/facebook',
preview=True)

0 comments on commit 0e44fe2

Please sign in to comment.