Skip to content

Commit 7bd3a6d

Browse files
committed
handlers: bug fix for f823e41: pass fetch_likes, etc when prefetching posts
i haven't come up with a good (or even mediocre) test for this yet :/
1 parent a6805d4 commit 7bd3a6d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

handlers.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,19 @@ def get_title(self, obj):
105105
"""
106106
return obj.get('title') or obj.get('content') or 'Bridgy Response'
107107

108-
def get_post(self, id):
108+
def get_post(self, id, **kwargs):
109109
"""Fetch a post.
110110
111111
Args:
112112
id: string, site-specific post id
113113
is_event: bool
114+
kwargs: passed through to get_activities
114115
115116
Returns: ActivityStreams object dict
116117
"""
117118
try:
118119
posts = self.source.get_activities(
119-
activity_id=id, user_id=self.source.key.id())
120+
activity_id=id, user_id=self.source.key.id(), **kwargs)
120121
if posts:
121122
return posts[0]
122123
logging.warning('Source post %s not found', id)
@@ -242,7 +243,7 @@ def get_item(self, id):
242243

243244
class CommentHandler(ItemHandler):
244245
def get_item(self, post_id, id):
245-
post = self.get_post(post_id)
246+
post = self.get_post(post_id, fetch_replies=True)
246247
cmt = self.source.get_comment(
247248
id, activity_id=post_id, activity_author_id=self.source.key.id(),
248249
activity=post)
@@ -256,7 +257,7 @@ def get_item(self, post_id, id):
256257

257258
class LikeHandler(ItemHandler):
258259
def get_item(self, post_id, user_id):
259-
post = self.get_post(post_id)
260+
post = self.get_post(post_id, fetch_likes=True)
260261
like = self.source.get_like(self.source.key.string_id(), post_id, user_id,
261262
activity=post)
262263
if post:
@@ -294,7 +295,7 @@ def get_item(self, post_id, user_id, reaction_id):
294295

295296
class RepostHandler(ItemHandler):
296297
def get_item(self, post_id, share_id):
297-
post = self.get_post(post_id)
298+
post = self.get_post(post_id, fetch_shares=True)
298299
repost = self.source.gr_source.get_share(
299300
self.source.key.string_id(), post_id, share_id, activity=post)
300301
# webmention receivers don't want to see their own post in their

0 commit comments

Comments
 (0)