diff --git a/server/api/auth/register.post.ts b/server/api/auth/register.post.ts index 4e9cf83..20aa556 100644 --- a/server/api/auth/register.post.ts +++ b/server/api/auth/register.post.ts @@ -73,7 +73,7 @@ export default defineEventHandler(async (e): Promise => { logSession(e, await setUserSession(e, { user: { id: id.id, username: body.data.username, email: body.data.email, state: 0, signin: new Date(), permissions: [] } }) as UserSessionRequired); - runTask('mail', { + await runTask('mail', { payload: { type: 'mail', to: [body.data.email], diff --git a/server/api/users/[id]/revalidate.get.ts b/server/api/users/[id]/revalidate.get.ts index dcd0dd6..c9e43b7 100644 --- a/server/api/users/[id]/revalidate.get.ts +++ b/server/api/users/[id]/revalidate.get.ts @@ -46,7 +46,7 @@ export default defineEventHandler(async (e) => { return; } - runTask('mail', { + await runTask('mail', { payload: { type: 'mail', to: [session.user.email], diff --git a/server/tasks/pull.ts b/server/tasks/pull.ts index a5afdc9..6bd2913 100644 --- a/server/tasks/pull.ts +++ b/server/tasks/pull.ts @@ -1,6 +1,6 @@ import useDatabase from "~/composables/useDatabase"; import { extname, basename } from 'node:path'; -import type { File, FileType, Tag } from '~/types/api'; +import type { FileType } from '~/types/api'; import type { CanvasColor, CanvasContent } from "~/types/canvas"; import { explorerContentTable } from "~/db/schema"; @@ -25,9 +25,9 @@ export default defineTask({ recursive: true, per_page: 1000, } - }) as any; + }) as { tree: any[] } & Record; - const files: typeof explorerContentTable.$inferInsert = await Promise.all(tree.tree.filter((e: any) => !e.path.startsWith(".")).map(async (e: any) => { + const files: typeof explorerContentTable.$inferInsert = await Promise.all(tree.tree.filter((e: any) => !e.path.startsWith(".")).map(async (e, i) => { if(e.type === 'tree') { const title = basename(e.path); @@ -35,7 +35,7 @@ export default defineTask({ const path = (e.path as string).split('/').map(f => { const check = /(\d+)\. ?(.+)/gsmi.exec(f); return check && check[2] ? check[2] : f }).join('/'); return { path: path.toLowerCase().replaceAll(" ", "-").normalize("NFD").replace(/[\u0300-\u036f]/g, ""), - order: order && order[1] ? order[1] : 0, + order: i, title: order && order[2] ? order[2] : title, type: 'folder', content: null, @@ -53,7 +53,7 @@ export default defineTask({ return { path: (extension === '.md' ? path.replace(extension, '') : path).toLowerCase().replaceAll(" ", "-").normalize("NFD").replace(/[\u0300-\u036f]/g, ""), - order: order && order[1] ? order[1] : 0, + order: i, title: order && order[2] ? order[2] : title, type: (typeMapping[extension] ?? 'file'), content: reshapeContent(content as string, typeMapping[extension] ?? 'File'),