feat(backend): Add Clone Endpoint
This commit is contained in:
parent
8926ba06a6
commit
ebf21b474a
4 changed files with 121 additions and 0 deletions
|
|
@ -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 });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue