Adding story_hash to interactions and activities. (For #693). Note that comment_like's may have a null story_hash, although future comment_like's wont.

This commit is contained in:
Samuel Clay 2015-06-04 15:38:21 -07:00
parent e0b4c1fc64
commit b65c157d86
2 changed files with 16 additions and 2 deletions

View file

@ -2761,6 +2761,10 @@ class MInteraction(mongo.Document):
self.category, self.content and self.content[:20])
def canonical(self):
story_hash = None
if self.story_feed_id:
story_hash = MStory.ensure_story_hash(self.content_id, story_feed_id=self.story_feed_id)
return {
'date': self.date,
'category': self.category,
@ -2770,6 +2774,7 @@ class MInteraction(mongo.Document):
'feed_id': self.feed_id,
'story_feed_id': self.story_feed_id,
'content_id': self.content_id,
'story_hash': story_hash,
}
@classmethod
@ -2885,11 +2890,12 @@ class MInteraction(mongo.Document):
cls.publish_update_to_subscribers(user_id)
@classmethod
def new_comment_like(cls, liking_user_id, comment_user_id, story_id, story_title, comments):
def new_comment_like(cls, liking_user_id, comment_user_id, story_id, story_feed_id, story_title, comments):
cls.objects.get_or_create(user_id=comment_user_id,
with_user_id=liking_user_id,
category="comment_like",
feed_id="social:%s" % comment_user_id,
story_feed_id=story_feed_id,
content_id=story_id,
defaults={
"title": story_title,
@ -2992,6 +2998,10 @@ class MActivity(mongo.Document):
return "<%s> %s - %s" % (user.username, self.category, self.content and self.content[:20])
def canonical(self):
story_hash = None
if self.story_feed_id:
story_hash = MStory.ensure_story_hash(self.content_id, story_feed_id=self.story_feed_id)
return {
'date': self.date,
'category': self.category,
@ -3002,6 +3012,7 @@ class MActivity(mongo.Document):
'feed_id': self.feed_id or self.story_feed_id,
'story_feed_id': self.story_feed_id or self.feed_id,
'content_id': self.content_id,
'story_hash': story_hash,
}
@classmethod
@ -3127,11 +3138,12 @@ class MActivity(mongo.Document):
original.delete()
@classmethod
def new_comment_like(cls, liking_user_id, comment_user_id, story_id, story_title, comments):
def new_comment_like(cls, liking_user_id, comment_user_id, story_id, story_feed_id, story_title, comments):
cls.objects.get_or_create(user_id=liking_user_id,
with_user_id=comment_user_id,
category="comment_like",
feed_id="social:%s" % comment_user_id,
story_feed_id=story_feed_id,
content_id=story_id,
defaults={
"title": story_title,

View file

@ -1185,11 +1185,13 @@ def like_comment(request):
MActivity.new_comment_like(liking_user_id=request.user.pk,
comment_user_id=comment['user_id'],
story_id=story_id,
story_feed_id=feed_id,
story_title=shared_story.story_title,
comments=shared_story.comments)
MInteraction.new_comment_like(liking_user_id=request.user.pk,
comment_user_id=comment['user_id'],
story_id=story_id,
story_feed_id=feed_id,
story_title=shared_story.story_title,
comments=shared_story.comments)