chore: generate

This commit is contained in:
opencode-agent[bot] 2026-06-24 10:09:04 +00:00
parent 05f335ce62
commit fe655b7630
4 changed files with 32 additions and 28 deletions

View File

@ -20,7 +20,5 @@ export async function POST(event: APIEvent) {
} }
return Referral.create(body.data) return Referral.create(body.data)
.then((result) => Response.json({ success: true, message: "Referral created", result })) .then((result) => Response.json({ success: true, message: "Referral created", result }))
.catch((error) => .catch((error) => Response.json({ error: error instanceof Error ? error.message : String(error) }, { status: 400 }))
Response.json({ error: error instanceof Error ? error.message : String(error) }, { status: 400 }),
)
} }

View File

@ -17,7 +17,5 @@ export async function DELETE(event: APIEvent) {
} }
return Account.remove(body.data.email) return Account.remove(body.data.email)
.then(() => Response.json({ success: true, message: "Account deleted" })) .then(() => Response.json({ success: true, message: "Account deleted" }))
.catch((error) => .catch((error) => Response.json({ error: error instanceof Error ? error.message : String(error) }, { status: 400 }))
Response.json({ error: error instanceof Error ? error.message : String(error) }, { status: 400 }),
)
} }

View File

@ -38,25 +38,35 @@ export namespace Account {
.select({ email: AuthTable.subject }) .select({ email: AuthTable.subject })
.from(AuthTable) .from(AuthTable)
.where(and(eq(AuthTable.accountID, account.id), eq(AuthTable.provider, "email"))) .where(and(eq(AuthTable.accountID, account.id), eq(AuthTable.provider, "email")))
const users = await tx const users = await tx.select({ id: UserTable.id }).from(UserTable).where(eq(UserTable.accountID, account.id))
.select({ id: UserTable.id })
.from(UserTable)
.where(eq(UserTable.accountID, account.id))
if (users.length > 0) { if (users.length > 0) {
await tx await tx
.update(KeyTable) .update(KeyTable)
.set({ timeDeleted: sql`now()` }) .set({ timeDeleted: sql`now()` })
.where(inArray(KeyTable.userID, users.map((user) => user.id))) .where(
inArray(
KeyTable.userID,
users.map((user) => user.id),
),
)
} }
await tx await tx
.update(UserTable) .update(UserTable)
.set({ accountID: null, email: null, name: "", timeDeleted: sql`now()` }) .set({ accountID: null, email: null, name: "", timeDeleted: sql`now()` })
.where(eq(UserTable.accountID, account.id)) .where(eq(UserTable.accountID, account.id))
if (emails.length > 0) { if (emails.length > 0) {
await tx.delete(CouponTable).where(inArray(CouponTable.email, emails.map((row) => row.email))) await tx.delete(CouponTable).where(
inArray(
CouponTable.email,
emails.map((row) => row.email),
),
)
} }
await tx.delete(AuthTable).where(eq(AuthTable.accountID, account.id)) await tx.delete(AuthTable).where(eq(AuthTable.accountID, account.id))
await tx.update(AccountTable).set({ timeDeleted: sql`now()` }).where(eq(AccountTable.id, account.id)) await tx
.update(AccountTable)
.set({ timeDeleted: sql`now()` })
.where(eq(AccountTable.id, account.id))
}) })
}) })

View File

@ -139,22 +139,20 @@ app
return c.json({}) return c.json({})
}, },
) )
.post( .post("/support/actions/remove-share", async (c) => {
"/support/actions/remove-share", const authorization = c.req.header("authorization")
async (c) => { const expected = `Bearer ${(Resource as unknown as Record<string, { value: string }>).SUPPORT_API_KEY.value}`
const authorization = c.req.header("authorization") const actual = Buffer.from(authorization ?? "")
const expected = `Bearer ${(Resource as unknown as Record<string, { value: string }>).SUPPORT_API_KEY.value}` const secret = Buffer.from(expected)
const actual = Buffer.from(authorization ?? "") if (actual.length !== secret.length || !timingSafeEqual(actual, secret))
const secret = Buffer.from(expected) return c.json({ error: "Unauthorized" }, 401)
if (actual.length !== secret.length || !timingSafeEqual(actual, secret)) return c.json({ error: "Unauthorized" }, 401)
const body = z.object({ shareID: z.string().min(1) }).safeParse(await c.req.json().catch(() => undefined)) const body = z.object({ shareID: z.string().min(1) }).safeParse(await c.req.json().catch(() => undefined))
if (!body.success) return c.json({ error: "Invalid request", issues: body.error.issues }, 400) if (!body.success) return c.json({ error: "Invalid request", issues: body.error.issues }, 400)
return Share.removeAdmin({ id: body.data.shareID }) return Share.removeAdmin({ id: body.data.shareID })
.then(() => c.json({ success: true, message: "Share removed" })) .then(() => c.json({ success: true, message: "Share removed" }))
.catch((error) => c.json({ error: error instanceof Error ? error.message : String(error) }, 400)) .catch((error) => c.json({ error: error instanceof Error ? error.message : String(error) }, 400))
}, })
)
export function GET(event: APIEvent) { export function GET(event: APIEvent) {
return app.fetch(event.request) return app.fetch(event.request)