feat : update i guess
CI / Verify (push) Failing after 1m4s
CI / Build immutable images and deploy (push) Skipped

This commit is contained in:
2026-10-03 15:47:47 +07:00 Unverified
parent f5cfe0a22e
commit 95c45841e7
15 changed files with 4297 additions and 174 deletions
@@ -17,16 +17,20 @@ export async function DELETE(request: Request,
const { ticket, user } = await authorizeTicket(id);
if (ticket.status !== "open") throw new HttpError(409, "ticket-closed");
await limitRequest("commission-message-delete", user.id, 30);
const imageObjectKey = await getDb().transaction(async (tx) => {
const imageObjectKeys = await getDb().transaction(async (tx) => {
const [message] = await tx.delete(commissionMessages)
.where(and(eq(commissionMessages.id, messageId), eq(commissionMessages.ticketId, id),
eq(commissionMessages.authorId, user.id)))
.returning({ imageObjectKey: commissionMessages.imageObjectKey });
.returning({ imageObjectKey: commissionMessages.imageObjectKey,
imageObjectKeys: commissionMessages.imageObjectKeys });
if (!message) throw new HttpError(404, "message-not-found");
await tx.update(commissionTickets).set({ updatedAt: new Date() }).where(eq(commissionTickets.id, id));
return message.imageObjectKey;
return [message.imageObjectKey, ...message.imageObjectKeys].filter((key): key is string => Boolean(key));
});
if (imageObjectKey) await (await getMediaStorage()).delete(imageObjectKey).catch(() => undefined);
if (imageObjectKeys.length) {
const storage = await getMediaStorage();
await Promise.all(imageObjectKeys.map((key) => storage.delete(key).catch(() => undefined)));
}
await notifyCommission(id, ticket.userId);
return new Response(null, { status: 204 });
} catch (cause) { return errorResponse(cause); }