This repository has no description
0

Configure Feed

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

core / web / src / lib / api / reaction.ts
1.2 kB 37 lines
1import { ok } from "@atcute/client"; 2import { mainSchema as putRecordSchema } from "@atcute/atproto/types/repo/putRecord"; 3import { mainSchema as deleteRecordSchema } from "@atcute/atproto/types/repo/deleteRecord"; 4import type { Nsid, RecordKey } from "@atcute/lexicons/syntax"; 5import type { OAuthUserAgent } from "@atcute/oauth-browser-client"; 6import { createClient } from "$lib/auth/agent"; 7import type { ReactionRecord, RecordView } from "./records"; 8 9const REACTION_COLLECTION = "sh.tangled.feed.reaction" as Nsid; 10 11export const putReaction = async ( 12 agent: OAuthUserAgent, 13 rkey: string, 14 record: ReactionRecord 15): Promise<RecordView<ReactionRecord>> => { 16 const rpc = createClient(agent); 17 const { uri, cid } = await ok( 18 rpc.call(putRecordSchema, { 19 input: { 20 repo: agent.sub, 21 collection: REACTION_COLLECTION, 22 rkey: rkey as RecordKey, 23 record 24 } 25 }) 26 ); 27 return { uri, cid, value: record }; 28}; 29 30export const deleteReaction = async (agent: OAuthUserAgent, rkey: string): Promise<void> => { 31 const rpc = createClient(agent); 32 await ok( 33 rpc.call(deleteRecordSchema, { 34 input: { repo: agent.sub, collection: REACTION_COLLECTION, rkey: rkey as RecordKey } 35 }) 36 ); 37};