Permalink
Browse files

Marking shared stories as read even if they dont have an associated f…

…eed.
  • Loading branch information...
1 parent 133a5c4 commit bf5d600a71d3bc8998edc218684b5cb0a9ba2212 @samuelclay committed Jul 6, 2013
Showing with 14 additions and 6 deletions.
  1. +14 −6 apps/api/views.py
View
@@ -13,7 +13,7 @@
from apps.profile.models import Profile
from apps.social.models import MSocialProfile, MSharedStory, MSocialSubscription
from apps.rss_feeds.models import Feed
-from apps.reader.models import UserSubscription, UserSubscriptionFolders
+from apps.reader.models import UserSubscription, UserSubscriptionFolders, RUserStory
from utils import json_functions as json
from utils import log as logging
from utils.feed_functions import relative_timesince
@@ -297,11 +297,19 @@ def share_story(request, token):
shared_story.save()
logging.user(profile.user, "~BM~FY~SBUpdating~SN shared story from site: ~SB%s: %s" % (story_url, comments))
- socialsub = MSocialSubscription.objects.get(user_id=profile.user.pk,
- subscription_user_id=profile.user.pk)
- socialsub.mark_story_ids_as_read([shared_story.story_hash],
- shared_story.story_feed_id,
- request=request)
+ try:
+ socialsub = MSocialSubscription.objects.get(user_id=profile.user.pk,
+ subscription_user_id=profile.user.pk)
+ except MSocialSubscription.DoesNotExist:
+ socialsub = None
+
+ if socialsub:
+ socialsub.mark_story_ids_as_read([shared_story.story_hash],
+ shared_story.story_feed_id,
+ request=request)
+ else:
+ RUserStory.mark_read(profile.user.pk, shared_story.story_feed_id, shared_story.story_hash)
+
shared_story.publish_update_to_subscribers()

0 comments on commit bf5d600

Please sign in to comment.