mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow storing annotations for anonymous users
This commit is contained in:
parent
14b87b8446
commit
928e31dbb6
@ -152,7 +152,7 @@ def book_manifest(ctx, rd, book_id, fmt):
|
|||||||
ans['metadata'] = book_as_json(db, book_id)
|
ans['metadata'] = book_as_json(db, book_id)
|
||||||
user = rd.username or None
|
user = rd.username or None
|
||||||
ans['last_read_positions'] = db.get_last_read_positions(book_id, fmt, user) if user else []
|
ans['last_read_positions'] = db.get_last_read_positions(book_id, fmt, user) if user else []
|
||||||
ans['annotations_map'] = db.annotations_map_for_book(book_id, fmt, user_type='web', user=user) if user else {}
|
ans['annotations_map'] = db.annotations_map_for_book(book_id, fmt, user_type='web', user=user or '*')
|
||||||
return ans
|
return ans
|
||||||
except EnvironmentError as e:
|
except EnvironmentError as e:
|
||||||
if e.errno != errno.ENOENT:
|
if e.errno != errno.ENOENT:
|
||||||
@ -234,9 +234,7 @@ def get_annotations(ctx, rd, library_id, which):
|
|||||||
book_id1-fmt1_book_id2-fmt2,...
|
book_id1-fmt1_book_id2-fmt2,...
|
||||||
'''
|
'''
|
||||||
db = get_db(ctx, rd, library_id)
|
db = get_db(ctx, rd, library_id)
|
||||||
user = rd.username or None
|
user = rd.username or '*'
|
||||||
if not user:
|
|
||||||
raise HTTPNotFound('login required for sync')
|
|
||||||
ans = {}
|
ans = {}
|
||||||
allowed_book_ids = ctx.allowed_book_ids(rd, db)
|
allowed_book_ids = ctx.allowed_book_ids(rd, db)
|
||||||
for item in which.split('_'):
|
for item in which.split('_'):
|
||||||
@ -258,9 +256,7 @@ def get_annotations(ctx, rd, library_id, which):
|
|||||||
@endpoint('/book-update-annotations/{library_id}/{book_id}/{+fmt}', types={'book_id': int}, methods=('POST',))
|
@endpoint('/book-update-annotations/{library_id}/{book_id}/{+fmt}', types={'book_id': int}, methods=('POST',))
|
||||||
def update_annotations(ctx, rd, library_id, book_id, fmt):
|
def update_annotations(ctx, rd, library_id, book_id, fmt):
|
||||||
db = get_db(ctx, rd, library_id)
|
db = get_db(ctx, rd, library_id)
|
||||||
user = rd.username or None
|
user = rd.username or '*'
|
||||||
if not user:
|
|
||||||
raise HTTPNotFound('login required for sync')
|
|
||||||
if not ctx.has_id(rd, db, book_id):
|
if not ctx.has_id(rd, db, book_id):
|
||||||
raise BookNotFound(book_id, db)
|
raise BookNotFound(book_id, db)
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user