feat: invitation deletion
Deploy On Server / Prepare Repository Remotely (push) Successful in 10s
Deploy On Server / Docker Compose Up (push) Successful in 18s
Deploy On Server / Prune Images (push) Successful in 3s
Deploy On Server / Remove .env File (push) Successful in 2s

This commit is contained in:
Raul Lugo
2026-08-11 22:18:25 +02:00
parent d4c542b93b
commit aed8684e09
7 changed files with 377 additions and 2 deletions
+63
View File
@@ -75,6 +75,69 @@ export async function createInvitationWithMembers(input: CreateInvitationInput)
})
}
export interface DeletedInvitationResult {
id: string
displayName: string
photoObjectKey: string | null
}
export async function deleteInvitationGroup(
invitationId: string,
adminEmail: string,
): Promise<DeletedInvitationResult | null> {
return db.transaction().execute(async (trx) => {
const invitation = await trx
.selectFrom("invitations")
.select(["id", "display_name", "token"])
.where("id", "=", invitationId)
.executeTakeFirst()
if (!invitation) return null
const photoUpload = await trx
.selectFrom("photo_uploads")
.select(["object_key"])
.where("invitation_id", "=", invitationId)
.executeTakeFirst()
const membersCount = await trx
.selectFrom("invitation_members")
.select((eb) => eb.fn.countAll<string>().as("count"))
.where("invitation_id", "=", invitationId)
.executeTakeFirst()
await trx
.insertInto("admin_audit_events")
.values({
admin_email: adminEmail,
action: "invitation.deleted",
target_type: "invitation",
target_id: invitationId,
metadata: {
displayName: invitation.display_name,
token: invitation.token,
membersCount: Number(membersCount?.count ?? 0),
photoObjectKey: photoUpload?.object_key ?? null,
},
})
.execute()
const deleted = await trx
.deleteFrom("invitations")
.where("id", "=", invitationId)
.returning(["id", "display_name"])
.executeTakeFirst()
if (!deleted) return null
return {
id: deleted.id,
displayName: deleted.display_name,
photoObjectKey: photoUpload?.object_key ?? null,
}
})
}
export async function listInvitations(): Promise<InvitationListItem[]> {
const invitations = await db
.selectFrom("invitations")
+5
View File
@@ -45,4 +45,9 @@ export const createInvitationSchema = z
path: ["members"],
})
export const deleteInvitationSchema = z.object({
invitationId: z.uuid(),
})
export type CreateInvitationInput = z.infer<typeof createInvitationSchema>
export type DeleteInvitationInput = z.infer<typeof deleteInvitationSchema>