decentralised sync engine
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: rename function, loosen function signature

serenity 2b18a611 022ad99d

+14 -8
+2 -2
src/index.ts
··· 2 2 import { connectToShards, performHandshakes } from "@/lib/setup"; 3 3 import { handshakeTokens, setRegistrationState } from "@/lib/state"; 4 4 import type { AtUri } from "@/lib/types/atproto"; 5 - import { getRecordFromAtUri } from "@/lib/utils/atproto"; 5 + import { getRecordFromFullAtUri } from "@/lib/utils/atproto"; 6 6 import { newErrorResponse } from "@/lib/utils/http/responses"; 7 7 import { connectToPrism } from "@/lib/utils/prism"; 8 8 import { ··· 78 78 rKey: latticeUrlOrigin, 79 79 }; 80 80 81 - const latticeRecord = await getRecordFromAtUri(latticeAtUri); 81 + const latticeRecord = await getRecordFromFullAtUri(latticeAtUri); 82 82 83 83 if (latticeRecord.ok) { 84 84 setRegistrationState(true);
+2 -2
src/lib/setup.ts
··· 3 3 import { systemsGmstnDevelopmentChannelRecordSchema } from "@/lib/types/lexicon/systems.gmstn.development.channel"; 4 4 import { 5 5 atUriToString, 6 - getRecordFromAtUri, 6 + getRecordFromFullAtUri, 7 7 stringToAtUri, 8 8 } from "@/lib/utils/atproto"; 9 9 import { getConstellationBacklink } from "@/lib/utils/constellation"; ··· 34 34 35 35 const channelRecordsPromises = channelBacklinks.map( 36 36 async ({ did, collection, rkey }) => 37 - await getRecordFromAtUri({ 37 + await getRecordFromFullAtUri({ 38 38 // @ts-expect-error seriously i gotta do something about the template literals not converting properly SIGH 39 39 authority: did, 40 40 collection,
+8 -2
src/lib/utils/atproto.ts
··· 22 22 } from "@atcute/identity-resolver"; 23 23 import { z } from "zod"; 24 24 25 - export const getRecordFromAtUri = async ({ 25 + export const getRecordFromFullAtUri = async ({ 26 26 authority, 27 27 collection, 28 28 rKey, 29 - }: Required<AtUri>): Promise<Result<unknown, unknown>> => { 29 + }: AtUri): Promise<Result<unknown, unknown>> => { 30 30 const didDocResult = await resolveDidDoc(authority); 31 31 if (!didDocResult.ok) return { ok: false, error: didDocResult.error }; 32 + 33 + if (!collection || !rKey) 34 + return { 35 + ok: false, 36 + error: "No rkey or collection found in provided AtUri object", 37 + }; 32 38 33 39 const { service: services } = didDocResult.data; 34 40 if (!services)
+2 -2
src/lib/utils/constellation.ts
··· 5 5 ConstellationBacklinkResponse, 6 6 } from "@/lib/types/constellation"; 7 7 import { constellationBacklinkResponseSchema } from "@/lib/types/constellation"; 8 - import { getRecordFromAtUri } from "@/lib/utils/atproto"; 8 + import { getRecordFromFullAtUri } from "@/lib/utils/atproto"; 9 9 import type { Result } from "@/lib/utils/result"; 10 10 import type { ZodError } from "zod"; 11 11 ··· 57 57 backlink: ConstellationBacklink, 58 58 ): Promise<Result<unknown, unknown>> => { 59 59 const atUri = createAtUriFromBacklink(backlink); 60 - const atUriRecordResult = await getRecordFromAtUri(atUri); 60 + const atUriRecordResult = await getRecordFromFullAtUri(atUri); 61 61 if (!atUriRecordResult.ok) 62 62 return { ok: false, error: atUriRecordResult.error }; 63 63 return { ok: true, data: atUriRecordResult.data };