@@ -319,31 +319,33 @@ async def on_GET(
319319 )
320320
321321 start_ts = 0
322- # start_index = 0
323- if '-' in start : # indicates we have a next_batch token
322+ start_index = 0
323+ if "-" in start : # indicates we have a next_batch token
324324 # Batch tokens are structured as `timestamp-index`, where `index` is relative
325325 # to the timestamp. This is done to support pages having many records with
326326 # the same timestamp (like existing servers having a ton of `ts=0` records).
327327 #
328328 # Dev note: The structure of the `from` token is partially documented in the
329329 # admin API. Do not change the behaviour without consulting the docs.
330- parts = start .split ('-' , maxsplit = 1 )
330+ parts = start .split ("-" , maxsplit = 1 )
331331 start_ts = int (parts [0 ])
332332 start_index = int (parts [1 ])
333- else :
333+ elif len ( start ) > 0 :
334334 start_index = int (start )
335335
336336 mxcs_with_ts = await self .store .get_quarantined_media_mxcs_and_timestamps (
337337 start_ts , start_index , limit , local_or_remote == "local"
338338 )
339339
340340 res : JsonDict = {
341- "media" : ( mxc for mxc , _ in mxcs_with_ts ) ,
341+ "media" : [ mxc for mxc , _ in mxcs_with_ts ] ,
342342 }
343343
344344 if len (mxcs_with_ts ) > 0 :
345345 max_ts = mxcs_with_ts [- 1 ][1 ] if mxcs_with_ts else 0
346- count_of_max_ts = sum (1 for _ , ts in mxcs_with_ts if ts == max_ts )
346+ count_of_max_ts = (
347+ sum (1 for _ , ts in mxcs_with_ts if ts == max_ts ) + start_index
348+ )
347349 res ["next_batch" ] = f"{ max_ts } -{ count_of_max_ts } "
348350
349351 return HTTPStatus .OK , res
0 commit comments