feat: Add team deletion flow for cloud-hosted (#5717)
This commit is contained in:
33
server/commands/teamDestroyer.ts
Normal file
33
server/commands/teamDestroyer.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Transaction } from "sequelize";
|
||||
import { Event, User, Team } from "@server/models";
|
||||
|
||||
export default async function teamDestroyer({
|
||||
user,
|
||||
team,
|
||||
ip,
|
||||
transaction,
|
||||
}: {
|
||||
user: User;
|
||||
team: Team;
|
||||
ip: string;
|
||||
transaction?: Transaction;
|
||||
}) {
|
||||
await Event.create(
|
||||
{
|
||||
name: "teams.delete",
|
||||
actorId: user.id,
|
||||
teamId: team.id,
|
||||
data: {
|
||||
name: team.name,
|
||||
},
|
||||
ip,
|
||||
},
|
||||
{
|
||||
transaction,
|
||||
}
|
||||
);
|
||||
|
||||
return team.destroy({
|
||||
transaction,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user