Various AT Protocol integrations with obsidian
20
fork

Configure Feed

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

check responses

+13 -3
+13 -3
src/lib/atproto.ts
··· 2 2 import type { ActorIdentifier, Nsid } from "@atcute/lexicons"; 3 3 4 4 export async function getRecord(client: Client, repo: string, collection: string, rkey: string) { 5 - return await client.get("com.atproto.repo.getRecord", { 5 + const resp = await client.get("com.atproto.repo.getRecord", { 6 6 params: { 7 7 repo: repo as ActorIdentifier, 8 8 collection: collection as Nsid, 9 9 rkey, 10 10 }, 11 11 }); 12 + if (!resp.ok) { 13 + throw new Error(`Failed to get record: ${resp.status} ${resp.data?.message || ""}`); 14 + } 15 + return resp 12 16 } 13 17 14 18 export async function deleteRecord(client: Client, repo: string, collection: string, rkey: string) { 15 - return await client.post("com.atproto.repo.deleteRecord", { 19 + const resp = await client.post("com.atproto.repo.deleteRecord", { 16 20 input: { 17 21 repo: repo as ActorIdentifier, 18 22 collection: collection as Nsid, 19 23 rkey, 20 24 }, 21 25 }); 26 + if (!resp.ok) { 27 + throw new Error(`Failed to delete record: ${resp.status} ${resp.data?.message || ""}`); 28 + } 22 29 } 23 30 24 31 export async function putRecord<T = unknown>(client: Client, repo: string, collection: string, rkey: string, record: T) { 25 - return await client.post("com.atproto.repo.putRecord", { 32 + const resp = await client.post("com.atproto.repo.putRecord", { 26 33 input: { 27 34 repo: repo as ActorIdentifier, 28 35 collection: collection as Nsid, ··· 30 37 record: record as unknown as { [key: string]: unknown }, 31 38 }, 32 39 }); 40 + if (!resp.ok) { 41 + throw new Error(`Failed to put record: ${resp.status} ${resp.data?.message || ""}`); 42 + } 33 43 } 34 44 35 45 export async function getProfile(client: Client, actor: string) {