mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Fixing unread counts when marking stories unread in social subs.
This commit is contained in:
parent
64159c363c
commit
89fb7a37d9
2 changed files with 23 additions and 3 deletions
|
@ -828,7 +828,6 @@ def mark_story_as_unread(request):
|
|||
usersub.save()
|
||||
|
||||
data = dict(code=0, payload=dict(story_id=story_id))
|
||||
logging.user(request, "~FY~SBUnread~SN story in feed: %s" % (feed))
|
||||
|
||||
story = MStory.objects(story_feed_id=feed_id, story_guid=story_id)[0]
|
||||
|
||||
|
@ -846,10 +845,18 @@ def mark_story_as_unread(request):
|
|||
# Mark stories as read only after the mark_read_date has been moved, otherwise
|
||||
# these would be ignored.
|
||||
data = usersub.mark_story_ids_as_read(newer_stories, request=request)
|
||||
|
||||
social_subs = MSocialSubscription.mark_dirty_sharing_story(user_id=request.user.pk,
|
||||
story_feed_id=feed_id,
|
||||
story_guid_hash=story.guid_hash)
|
||||
dirty_count = social_subs.count()
|
||||
dirty_count = ("(%s social_subs)" % dirty_count) if dirty_count else ""
|
||||
|
||||
m = MUserStory.objects(user_id=request.user.pk, feed_id=feed_id, story_id=story_id)
|
||||
m.delete()
|
||||
|
||||
logging.user(request, "~FY~SBUnread~SN story in feed: %s %s" % (feed, dirty_count))
|
||||
|
||||
return data
|
||||
|
||||
@ajax_login_required
|
||||
|
|
|
@ -762,7 +762,20 @@ class MSocialSubscription(mongo.Document):
|
|||
logging.info(' ---> [%s] Computing social scores: %s (%s/%s/%s)' % (user.username, self.subscription_user_id, feed_scores['negative'], feed_scores['neutral'], feed_scores['positive']))
|
||||
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def mark_dirty_sharing_story(cls, user_id, story_feed_id, story_guid_hash):
|
||||
r = redis.Redis(connection_pool=settings.REDIS_POOL)
|
||||
|
||||
friends_key = "F:%s:F" % (user_id)
|
||||
share_key = "S:%s:%s" % (story_feed_id, story_guid_hash)
|
||||
following_user_ids = r.sinter(friends_key, share_key)
|
||||
following_user_ids = [int(f) for f in following_user_ids]
|
||||
social_subs = cls.objects.filter(user_id=user_id, subscription_user_id__in=following_user_ids)
|
||||
for social_sub in social_subs:
|
||||
social_sub.needs_unread_recalc = True
|
||||
social_sub.save()
|
||||
return social_subs
|
||||
|
||||
class MCommentReply(mongo.EmbeddedDocument):
|
||||
user_id = mongo.IntField()
|
||||
|
@ -964,8 +977,8 @@ class MSharedStory(mongo.Document):
|
|||
if user_id in seen_user_ids:
|
||||
return source_user_id
|
||||
else:
|
||||
seen.append(user_id)
|
||||
return find_source(user_id, seen)
|
||||
seen_user_ids.append(user_id)
|
||||
return find_source(user_id, seen_user_ids)
|
||||
else:
|
||||
return source_user_id
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue