/api/sync/?only=books: nur der Bücher-Teil
All checks were successful
Build and push Docker image / build (push) Successful in 16s
Test / test (push) Successful in 7m39s

Die Buch-Synchronisation der Apps braucht vom Schnappschuss nur Bücher,
Fortschritt, Markierungen und Lesezeichen; der Podcast-Teil (jede je gespielte
Folge) ist für ein Konto aus AntennaPod 11 MB groß und wurde bei jedem Abgleich
mitgeladen – über mobile Daten Gigabytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mrwnslz 2026-10-05 17:50:44 +02:00
parent 886c526201
commit 3d659fc809
2 changed files with 20 additions and 1 deletions

View file

@ -19,7 +19,11 @@ def sync_snapshot(request):
endpoints (e.g. GET /books/<id>/data/), which this same token also
unlocks. Writes (progress, highlights, bookmarks, ...) go through those
existing endpoints too, to reuse their merge semantics rather than
duplicating it here."""
duplicating it here.
?only=books: just the books' part. The apps' book sync needs nothing else,
and the podcast part is by far the biggest (every episode ever played:
megabytes for an account that moved over from AntennaPod)."""
if not request.user.is_authenticated:
return JsonResponse({'error': 'authentication required'}, status=401)
@ -43,6 +47,15 @@ def sync_snapshot(request):
for bm in book_bookmarks:
bm['updated_at'] = bm['updated_at'].isoformat()
if request.GET.get('only') == 'books':
return JsonResponse({
'server_time': timezone.now().isoformat(),
'books': books,
'book_progress': book_progress,
'book_highlights': book_highlights,
'book_bookmarks': book_bookmarks,
})
podcast_feeds = list(
PodcastFeed.objects.filter(user=user)
.annotate(latest_episode_at=Max('episodes__pub_date'))

View file

@ -85,6 +85,12 @@ class SyncSnapshotTests(TestCase):
resp = self.client.get('/api/sync/')
self.assertEqual(resp.status_code, 401)
def test_only_books(self):
resp = self.client.get('/api/sync/?only=books', HTTP_AUTHORIZATION=f'Bearer {self.token.token}')
data = resp.json()
self.assertEqual(set(data), {'server_time', 'books', 'book_progress', 'book_highlights', 'book_bookmarks'})
self.assertEqual(data['book_highlights'][0]['ct'], 'hl-ct')
def test_snapshot_shape_and_data(self):
resp = self.client.get('/api/sync/', HTTP_AUTHORIZATION=f'Bearer {self.token.token}')
self.assertEqual(resp.status_code, 200)