mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-31 13:35:58 +00:00
Merge branch 'master' into circular
* master: New API endpoint: /reader/unread_story_hashes.
This commit is contained in:
commit
bd03e24c8f
3 changed files with 34 additions and 1 deletions
|
@ -18,6 +18,7 @@ urlpatterns = patterns('',
|
|||
url(r'^interactions_count', views.interactions_count, name='interactions-count'),
|
||||
url(r'^feed_unread_count', views.feed_unread_count, name='feed-unread-count'),
|
||||
url(r'^starred_stories', views.load_starred_stories, name='load-starred-stories'),
|
||||
url(r'^unread_story_hashes', views.unread_story_hashes, name='unread-story-hashes'),
|
||||
url(r'^mark_all_as_read', views.mark_all_as_read, name='mark-all-as-read'),
|
||||
url(r'^mark_story_as_read', views.mark_story_as_read, name='mark-story-as-read'),
|
||||
url(r'^mark_feed_stories_as_read', views.mark_feed_stories_as_read, name='mark-feed-stories-as-read'),
|
||||
|
|
|
@ -841,7 +841,27 @@ def load_river_stories__redis(request):
|
|||
elapsed_time=timediff,
|
||||
user_profiles=user_profiles)
|
||||
|
||||
|
||||
@json.json_view
|
||||
def unread_story_hashes(request):
|
||||
user = get_user(request)
|
||||
feed_ids = [int(feed_id) for feed_id in request.REQUEST.getlist('feed_id') if feed_id]
|
||||
|
||||
if not feed_ids:
|
||||
usersubs = UserSubscription.objects.filter(user=user, active=True).only('feed')
|
||||
feed_ids = [sub.feed_id for sub in usersubs]
|
||||
|
||||
unread_feed_story_hashes = {}
|
||||
for feed_id in feed_ids:
|
||||
try:
|
||||
us = UserSubscription.objects.get(user=user.pk, feed=feed_id)
|
||||
except UserSubscription.DoesNotExist:
|
||||
continue
|
||||
unread_feed_story_hashes[feed_id] = us.get_stories(read_filter='unread', limit=500,
|
||||
hashes_only=True)
|
||||
|
||||
return dict(unread_feed_story_hashes=unread_feed_story_hashes)
|
||||
|
||||
@ajax_login_required
|
||||
@json.json_view
|
||||
def mark_all_as_read(request):
|
||||
|
|
|
@ -234,7 +234,19 @@
|
|||
optional: true
|
||||
default: unread
|
||||
example: all
|
||||
|
||||
|
||||
- url: /reader/unread_story_hashes
|
||||
method: GET
|
||||
short_desc: "The story_hashes of all unread stories."
|
||||
long_desc:
|
||||
- "The story_hashes of all unread stories."
|
||||
- "Useful for offline access of stories and quick unread syncing."
|
||||
params:
|
||||
- key: feed_id
|
||||
desc: "Feed ids to check. Omit to include every feed subscription."
|
||||
optional: true
|
||||
example: "feed_id=12&feed_id=24"
|
||||
|
||||
- url: /reader/mark_story_as_read
|
||||
method: POST
|
||||
short_desc: "Mark a story as read."
|
||||
|
|
Loading…
Add table
Reference in a new issue