aboutsummaryrefslogtreecommitdiff
path: root/src/routes/api
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-01-02 21:47:28 -0800
committerFuwn <[email protected]>2024-01-02 21:47:28 -0800
commitc0e4dc886eaba03485ea4aaac37eaffb311aeb74 (patch)
tree70cbc8aa9fd46ee0eb3216e52e8c797e035cc747 /src/routes/api
parentfix(badges): datetime update (diff)
downloaddue.moe-c0e4dc886eaba03485ea4aaac37eaffb311aeb74.tar.xz
due.moe-c0e4dc886eaba03485ea4aaac37eaffb311aeb74.zip
feat(badges): categories
Diffstat (limited to 'src/routes/api')
-rw-r--r--src/routes/api/badges/+server.ts31
1 files changed, 4 insertions, 27 deletions
diff --git a/src/routes/api/badges/+server.ts b/src/routes/api/badges/+server.ts
index fc5a4d0a..63e6ace4 100644
--- a/src/routes/api/badges/+server.ts
+++ b/src/routes/api/badges/+server.ts
@@ -49,41 +49,18 @@ export const PUT = async ({ cookies, url }) => {
post: url.searchParams.get('post') || undefined,
image: url.searchParams.get('image') || undefined,
description: url.searchParams.get('description') || undefined,
- time: url.searchParams.get('time') || undefined
+ time: url.searchParams.get('time') || undefined,
+ category: url.searchParams.get('category') || undefined
});
} else {
addUserBadge(identity.id, {
post: url.searchParams.get('post') || undefined,
image: url.searchParams.get('image') || undefined,
description: url.searchParams.get('description') || undefined,
- time: url.searchParams.get('time') || undefined
+ time: url.searchParams.get('time') || undefined,
+ category: url.searchParams.get('category') || undefined
});
}
return Response.json({});
};
-
-export const PATCH = async ({ cookies, url }) => {
- const userCookie = cookies.get('user');
-
- if (!userCookie) {
- return new Response('Unauthenticated', { status: 401 });
- }
-
- const user = JSON.parse(userCookie);
- const identity = await userIdentity({
- tokenType: user['token_type'],
- expiresIn: user['expires_in'],
- accessToken: user['access_token'],
- refreshToken: user['refresh_token']
- });
-
- updateUserBadge(identity.id, Number(url.searchParams.get('id')), {
- post: url.searchParams.get('post') || undefined,
- image: url.searchParams.get('image') || undefined,
- description: url.searchParams.get('description') || undefined,
- time: url.searchParams.get('time') || undefined
- });
-
- return Response.json({});
-};