···11-from core.models import Record
11+from core import lexicon
22+from core.models import AtUri, Record
233445def filter_moderated(
···89 return [
910 r
1011 for r in records
1111- if r.uri.split("/")[2] not in banned_dids and r.uri not in hidden_posts
1212+ if AtUri.parse(r.uri).did not in banned_dids and r.uri not in hidden_posts
1213 ]
···88from core import lexicon
99from core.constellation import get_replies, get_threads
1010from core.filters import filter_moderated
1111-from core.models import BBS, Board, Reply, Thread
1111+from core.models import AtUri, BBS, Board, Reply, Thread
1212from core.slingshot import get_records_batch, resolve_identities_batch
1313from core.util import now_iso
1414···2020 cursor: str | None = None,
2121) -> tuple[list[Thread], str | None]:
2222 """Fetch and hydrate threads for a board."""
2323- board_uri = f"at://{bbs.identity.did}/{lexicon.BOARD}/{board.slug}"
2323+ board_uri = str(AtUri(bbs.identity.did, lexicon.BOARD, board.slug))
2424 backlinks = await get_threads(client, board_uri, cursor=cursor)
2525 records = await get_records_batch(client, backlinks.records)
2626 records = filter_moderated(records, bbs.site.banned_dids, bbs.site.hidden_posts)
27272828- dids = [r.uri.split("/")[2] for r in records]
2828+ parsed = {r.uri: AtUri.parse(r.uri) for r in records}
2929+ dids = [p.did for p in parsed.values()]
2930 authors = await resolve_identities_batch(client, dids)
30313132 threads = [
···3536 title=r.value["title"],
3637 body=r.value["body"],
3738 created_at=r.value["createdAt"],
3838- author=authors[r.uri.split("/")[2]],
3939+ author=authors[parsed[r.uri].did],
3940 updated_at=r.value.get("updatedAt"),
4041 attachments=r.value.get("attachments"),
4142 )
4243 for r in records
4343- if r.uri.split("/")[2] in authors
4444+ if parsed[r.uri].did in authors
4445 ]
4546 threads.sort(key=lambda t: t.created_at, reverse=True)
4647 return threads, backlinks.cursor
···5758 records = await get_records_batch(client, backlinks.records)
5859 records = filter_moderated(records, bbs.site.banned_dids, bbs.site.hidden_posts)
59606060- dids = [r.uri.split("/")[2] for r in records]
6161+ parsed = {r.uri: AtUri.parse(r.uri) for r in records}
6262+ dids = [p.did for p in parsed.values()]
6163 authors = await resolve_identities_batch(client, dids)
62646365 replies = [
···6668 subject_uri=r.value["subject"],
6769 body=r.value["body"],
6870 created_at=r.value["createdAt"],
6969- author=authors[r.uri.split("/")[2]],
7171+ author=authors[parsed[r.uri].did],
7072 updated_at=r.value.get("updatedAt"),
7173 attachments=r.value.get("attachments"),
7274 quote=r.value.get("quote"),
7375 )
7476 for r in records
7575- if r.uri.split("/")[2] in authors
7777+ if parsed[r.uri].did in authors
7678 ]
7779 replies.sort(key=lambda t: t.created_at)
7880 return replies, backlinks.cursor
···326328 thread_uri = tr["uri"]
327329 thread_title = tr["value"].get("title", "")
328330 board_uri = tr["value"].get("board", "")
329329- bbs_did = board_uri.split("/")[2] if len(board_uri.split("/")) > 2 else did
331331+ bbs_did = AtUri.parse(board_uri).did if board_uri else did
330332 try:
331333 bbs_authors = await resolve_identities_batch(client, [bbs_did])
332334 bbs_handle = bbs_authors[bbs_did].handle if bbs_did in bbs_authors else ""
···336338 try:
337339 backlinks = await get_replies(client, thread_uri, limit=50)
338340 records = await get_records_batch(client, backlinks.records)
339339- records = [r for r in records if r.uri.split("/")[2] != did]
341341+ parsed = {r.uri: AtUri.parse(r.uri) for r in records}
342342+ records = [r for r in records if parsed[r.uri].did != did]
340343 if not records:
341344 continue
342345343343- dids = [r.uri.split("/")[2] for r in records]
346346+ dids = [parsed[r.uri].did for r in records]
344347 authors = await resolve_identities_batch(client, dids)
345348346349 for r in records:
347347- author_did = r.uri.split("/")[2]
350350+ author_did = parsed[r.uri].did
348351 if author_did not in authors:
349352 continue
350353 all_items.append(
···386389 continue
387390388391 records = await get_records_batch(client, backlinks.records)
389389- records = [r for r in records if r.uri.split("/")[2] != did]
392392+ parsed = {r.uri: AtUri.parse(r.uri) for r in records}
393393+ records = [r for r in records if parsed[r.uri].did != did]
390394 if not records:
391395 continue
392396393393- dids = [r.uri.split("/")[2] for r in records]
397397+ dids = [parsed[r.uri].did for r in records]
394398 authors = await resolve_identities_batch(client, dids)
395399396400 for r in records:
397397- author_did = r.uri.split("/")[2]
401401+ author_did = parsed[r.uri].did
398402 if author_did not in authors:
399403 continue
400404 all_items.append(