blob: b69a814202b059036c6c465a5b8afd99472108a4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import { safeUserIdentity } from "$lib/Data/AniList/identity";
import { decodeAuthCookieOrNull } from "$lib/Effect/authCookie";
import { toggleHololiveStreamPinning } from "$lib/Database/SB/User/preferences";
import { appOriginHeaders } from "$lib/Utility/appOrigin";
const unauthorised = new Response("Unauthorised", { status: 401 });
export const PUT = async ({ cookies, url }) => {
const userCookie = cookies.get("user");
if (!userCookie) return unauthorised;
const user = decodeAuthCookieOrNull(userCookie);
if (!user) return unauthorised;
const identity = await safeUserIdentity(user);
if (!identity) return unauthorised;
return Response.json(
await toggleHololiveStreamPinning(
identity.id,
url.searchParams.get("stream") || "",
),
{
headers: appOriginHeaders({
method: "PUT",
}),
},
);
};
|