feat(backend): Add Clone Endpoint

This commit is contained in:
Lilly Schramm 2025-06-20 20:27:20 +02:00
parent 8926ba06a6
commit ebf21b474a
4 changed files with 121 additions and 0 deletions

View file

@ -737,6 +737,20 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
}
}
@bindThis
public async clone(role: MiRole, moderator?: MiUser): Promise<MiRole> {
let newName = `${role.name} (cloned)`;
if (newName.length > 256) {
newName = newName.slice(0, 256);
}
return this.create({
...role,
name: newName,
}, moderator);
}
@bindThis
public async delete(role: MiRole, moderator?: MiUser): Promise<void> {
await this.rolesRepository.delete({ id: role.id });