[READ-ONLY] Mirror of https://github.com/flo-bit/skywatched. review movies and tv shows, based on at proto skywatched.app
0

Configure Feed

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

skywatched / src / routes / api / like / +server.ts
927 B 40 lines
1import { error, json, type RequestHandler } from '@sveltejs/kit'; 2import { AtpBaseClient } from '@atproto/api'; 3import { TID } from '@atproto/common'; 4 5export const POST: RequestHandler = async ({ request, locals }) => { 6 const user = locals.user; 7 const agent = locals.agent; 8 if (!user || !agent || agent instanceof AtpBaseClient) { 9 return error(401, 'Unauthorized API call'); 10 } 11 const body = await request.json(); 12 13 const cid = body.cid; 14 const uri = body.uri; 15 16 const did = user.did; 17 18 const rkey = TID.nextStr(); 19 20 const record: { 21 repo: string; 22 collection: string; 23 rkey: string; 24 record: { 25 subject: { cid: string; uri: string }; 26 createdAt: string; 27 }; 28 } = { 29 repo: did, 30 collection: 'community.lexicon.interaction.like', 31 rkey, 32 record: { 33 subject: { cid, uri }, 34 createdAt: new Date().toISOString() 35 } 36 }; 37 await agent.com.atproto.repo.putRecord(record); 38 39 return json({ status: 'liked' }); 40};