blob: 499e2cf0d924c92b8d444bb177de8f00544fbac0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import { userIdentity } from "$lib/Data/AniList/identity";
import { setUserSubscription } from "$lib/Database/SB/User/notifications";
import { decodeAuthCookieOrThrow } from "$lib/Effect/authCookie";
const unauthorised = new Response("Unauthorised", { status: 401 });
export const POST = async ({ cookies, request, url }) => {
const userCookie = cookies.get("user");
const fingerprint = url.searchParams.get("p");
if (!userCookie || !fingerprint) return unauthorised;
const user = decodeAuthCookieOrThrow(userCookie);
const userId = (await userIdentity(user)).id;
if (!userId) return unauthorised;
await setUserSubscription(userId, await request.json(), fingerprint);
return new Response(null, { status: 200 });
};
|