Merge lp:~kai-mast/friends/facebook-link-picture-size into lp:friends

Proposed by Kai Mast
Status: Merged
Merged at revision: 250
Proposed branch: lp:~kai-mast/friends/facebook-link-picture-size
Merge into: lp:friends
Diff against target: 95 lines (+28/-7)
4 files modified
friends/protocols/facebook.py (+22/-3)
friends/protocols/twitter.py (+3/-0)
friends/tests/test_facebook.py (+2/-3)
friends/tests/test_twitter.py (+1/-1)
To merge this branch: bzr merge lp:~kai-mast/friends/facebook-link-picture-size
Reviewer Review Type Date Requested Status
Robert Bruce Park Needs Fixing
Review via email: mp+203629@code.launchpad.net

Description of the change

Looks good to me now.

I also added the image stream stuff to Twitter too. Would really be nicer if messages could be in one than more stream though.

To post a comment you must log in.
Revision history for this message
Kai Mast (kai-mast) wrote :

Oh, I also filtered the wall posts out of the stream. They don't really make sense when displayed as normal posts.

Revision history for this message
Robert Bruce Park (robru) wrote :

Looks mostly good, but here's some improvements you can make:

    if (message_id is None) or (message_type is None):

should be:

    if None in (message_id, message_type):

and then:

    if to and not (to is ""):

Not sure what you're even trying to do here. if "to" is an empty string, it will evaluate false in python. So this is already equivalent:

    if to:

then:

    place = entry.get('place') or {}
    location = place.get('location') or {}

should be:

    place = entry.get('place', {})
    location = place.get('location', {})

and:

    if not (picture_url is ''):

can be:

    if picture_url:

review: Needs Fixing
234. By Kai Mast

Cleanups

Revision history for this message
Kai Mast (kai-mast) wrote :

Thanks for the hints. Still getting used to python. Should be cleaned up now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'friends/protocols/facebook.py'
--- friends/protocols/facebook.py 2013-11-05 20:22:00 +0000
+++ friends/protocols/facebook.py 2014-01-28 22:04:43 +0000
@@ -60,19 +60,38 @@
6060
61 def _publish_entry(self, entry, stream='messages'):61 def _publish_entry(self, entry, stream='messages'):
62 message_id = entry.get('id')62 message_id = entry.get('id')
63 if message_id is None:63 to = entry.get('to')
64 message_type = entry.get('type')
65
66 if "reply" in stream:
67 message_type = "reply"
68
69 if None in (message_id, message_type):
64 # We can't do much with this entry.70 # We can't do much with this entry.
65 return71 return
72
73 if to:
74 # Somebody posted on somebodies wall
75 # This cannot be displayed properly in friends so ignore
76 return
6677
67 place = entry.get('place', {})78 place = entry.get('place', {})
68 location = place.get('location', {})79 location = place.get('location', {})
6980
81 link_pic = entry.get('picture', '')
82
83 # Use objectID to get a highres version of the picture
84 # Does not seem to work for links
85 object_id = entry.get('object_id')
86 if object_id and ('photo' in message_type):
87 link_pic = "http://graph.facebook.com/" + object_id + "/picture?type=normal"
88
70 args = dict(89 args = dict(
71 message_id=message_id,90 message_id=message_id,
72 stream=stream,91 stream='images' if ('photo' in message_type) else stream,
73 message=entry.get('message', '') or entry.get('story', ''),92 message=entry.get('message', '') or entry.get('story', ''),
74 icon_uri=entry.get('icon', ''),93 icon_uri=entry.get('icon', ''),
75 link_picture=entry.get('picture', ''),94 link_picture=link_pic,
76 link_name=entry.get('name', ''),95 link_name=entry.get('name', ''),
77 link_url=entry.get('link', ''),96 link_url=entry.get('link', ''),
78 link_desc=entry.get('description', ''),97 link_desc=entry.get('description', ''),
7998
=== modified file 'friends/protocols/twitter.py'
--- friends/protocols/twitter.py 2014-01-24 18:11:23 +0000
+++ friends/protocols/twitter.py 2014-01-28 22:04:43 +0000
@@ -175,6 +175,9 @@
175 message175 message
176 )176 )
177177
178 if picture_url:
179 stream = 'images'
180
178 self._publish(181 self._publish(
179 message_id=tweet_id,182 message_id=tweet_id,
180 message=message,183 message=message,
181184
=== modified file 'friends/tests/test_facebook.py'
--- friends/tests/test_facebook.py 2013-07-29 22:10:41 +0000
+++ friends/tests/test_facebook.py 2014-01-28 22:04:43 +0000
@@ -173,7 +173,7 @@
173 'facebook',173 'facebook',
174 88,174 88,
175 '161247843901324_629147610444676',175 '161247843901324_629147610444676',
176 'mentions',176 'images',
177 'Best Western Denver Southwest',177 'Best Western Denver Southwest',
178 '161247843901324',178 '161247843901324',
179 'Best Western Denver Southwest',179 'Best Western Denver Southwest',
@@ -189,8 +189,7 @@
189 'https://www.facebook.com/161247843901324/posts/629147610444676',189 'https://www.facebook.com/161247843901324/posts/629147610444676',
190 84,190 84,
191 False,191 False,
192 'https://fbcdn-photos-a.akamaihd.net/hphotos-ak-snc7/' +192 'http://graph.facebook.com/629147587111345/picture?type=normal',
193 '601266_629147587111345_968504279_s.jpg',
194 '',193 '',
195 'https://www.facebook.com/photo.php?fbid=629147587111345&set=a.173256162700492.47377.161247843901324&type=1&relevant_count=1',194 'https://www.facebook.com/photo.php?fbid=629147587111345&set=a.173256162700492.47377.161247843901324&type=1&relevant_count=1',
196 '',195 '',
197196
=== modified file 'friends/tests/test_twitter.py'
--- friends/tests/test_twitter.py 2014-01-24 18:11:23 +0000
+++ friends/tests/test_twitter.py 2014-01-28 22:04:43 +0000
@@ -142,7 +142,7 @@
142 0, False, '', '', '', '', '', '', '', 0.0, 0.0,142 0, False, '', '', '', '', '', '', '', 0.0, 0.0,
143 ],143 ],
144 ['twitter', 88, '240556426106372096',144 ['twitter', 88, '240556426106372096',
145 'messages', 'Raffi Krikorian', '8285392', 'raffi', False,145 'images', 'Raffi Krikorian', '8285392', 'raffi', False,
146 '2012-08-28T21:08:15Z', 'lecturing at the "analyzing big data '146 '2012-08-28T21:08:15Z', 'lecturing at the "analyzing big data '
147 'with twitter" class at <a href="https://twitter.com/Cal">@Cal</a>'147 'with twitter" class at <a href="https://twitter.com/Cal">@Cal</a>'
148 ' with <a href="https://twitter.com/othman">@othman</a> '148 ' with <a href="https://twitter.com/othman">@othman</a> '

Subscribers

People subscribed via source and target branches

to all changes: