frontend client for gemstone. decentralised workplace app
1import type { AtUri } from "@/lib/types/atproto";
2import type { SystemsGmstnDevelopmentChannelInvite } from "@/lib/types/lexicon/systems.gmstn.development.channel.invite";
3import { systemsGmstnDevelopmentChannelInviteRecordSchema } from "@/lib/types/lexicon/systems.gmstn.development.channel.invite";
4import { getRecordFromFullAtUri } from "@/lib/utils/atproto";
5import type { Result } from "@/lib/utils/result";
6
7export const getInviteFromPds = async (
8 atUri: Required<AtUri>,
9): Promise<Result<SystemsGmstnDevelopmentChannelInvite, unknown>> => {
10 const record = await getRecordFromFullAtUri(atUri);
11 if (!record.ok) return { ok: false, error: record.error };
12
13 const {
14 success,
15 error,
16 data: invite,
17 } = systemsGmstnDevelopmentChannelInviteRecordSchema.safeParse(record.data);
18 if (!success) return { ok: false, error };
19
20 return { ok: true, data: invite };
21};