From a6b013473f951c96a80beb279e9773a69259b6f7 Mon Sep 17 00:00:00 2001 From: Jesse Winton Date: Fri, 2 Aug 2024 09:03:08 -0700 Subject: [PATCH] Update +server.ts --- .../init/tickets/get-ticket-doc/+server.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/routes/init/tickets/get-ticket-doc/+server.ts b/src/routes/init/tickets/get-ticket-doc/+server.ts index 2b927af071..f8a3645214 100644 --- a/src/routes/init/tickets/get-ticket-doc/+server.ts +++ b/src/routes/init/tickets/get-ticket-doc/+server.ts @@ -1,4 +1,5 @@ -import { APPWRITE_COL_INIT_TWO_ID, APPWRITE_DB_INIT_ID } from '$env/static/private'; +import { APPWRITE_DB_INIT_ID } from '$env/static/private'; +import { env } from '$env/dynamic/private'; import { appwriteInitServer } from '$lib/appwrite/init.server'; import { isProUser } from '$lib/utils/console.js'; import type { User } from '$routes/init/helpers.js'; @@ -35,14 +36,14 @@ async function getTicketDocByUser(user: User) { user.github?.login ? appwriteInitServer.databases.listDocuments( APPWRITE_DB_INIT_ID, - APPWRITE_COL_INIT_TWO_ID, + env.APPWRITE_COL_INIT_TWO_ID, [Query.equal('gh_user', user.github.login)] ) : null, user.appwrite?.$id ? appwriteInitServer.databases.listDocuments( APPWRITE_DB_INIT_ID, - APPWRITE_COL_INIT_TWO_ID, + env.APPWRITE_COL_INIT_TWO_ID, [Query.equal('aw_email', user.appwrite.email)] ) : null, @@ -59,7 +60,7 @@ async function getTicketDocByUser(user: User) { const newest = gh_doc.id > aw_doc.id ? gh_doc.$id : aw_doc.$id; await appwriteInitServer.databases.updateDocument( APPWRITE_DB_INIT_ID, - APPWRITE_COL_INIT_TWO_ID, + env.APPWRITE_COL_INIT_TWO_ID, oldest, { gh_user: null, @@ -68,7 +69,7 @@ async function getTicketDocByUser(user: User) { ); return (await appwriteInitServer.databases.updateDocument( APPWRITE_DB_INIT_ID, - APPWRITE_COL_INIT_TWO_ID, + env.APPWRITE_COL_INIT_TWO_ID, newest, { gh_user: user.github?.login, @@ -83,7 +84,7 @@ async function getTicketDocByUser(user: User) { if (!doc.gh_user || !doc.aw_email) { return (await appwriteInitServer.databases.updateDocument( APPWRITE_DB_INIT_ID, - APPWRITE_COL_INIT_TWO_ID, + env.APPWRITE_COL_INIT_TWO_ID, doc.$id, { gh_user: user.github?.login, @@ -96,7 +97,7 @@ async function getTicketDocByUser(user: User) { if (!!user.appwrite && doc.is_pro !== isPro) { return (await appwriteInitServer.databases.updateDocument( APPWRITE_DB_INIT_ID, - APPWRITE_COL_INIT_TWO_ID, + env.APPWRITE_COL_INIT_TWO_ID, doc.$id, { is_pro: isPro @@ -110,11 +111,11 @@ async function getTicketDocByUser(user: User) { // If no document exists, create one const allDocs = await appwriteInitServer.databases.listDocuments( APPWRITE_DB_INIT_ID, - APPWRITE_COL_INIT_TWO_ID + env.APPWRITE_COL_INIT_TWO_ID ); return (await appwriteInitServer.databases.createDocument( APPWRITE_DB_INIT_ID, - APPWRITE_COL_INIT_TWO_ID, + env.APPWRITE_COL_INIT_TWO_ID, ID.unique(), { aw_email: user.appwrite?.email ?? undefined, @@ -129,7 +130,7 @@ async function getTicketDocByUser(user: User) { async function getTicketDocById(id: string) { return (await appwriteInitServer.databases.getDocument( APPWRITE_DB_INIT_ID, - APPWRITE_COL_INIT_TWO_ID, + env.APPWRITE_COL_INIT_TWO_ID, id )) as unknown as Omit; }