mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-01 15:48:32 -04:00
feat: setupSpecialGroups in bootstrap
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
bcf35c61a5
commit
0470497ccb
2 changed files with 37 additions and 0 deletions
34
src/utils/createSpecialGroups.ts
Normal file
34
src/utils/createSpecialGroups.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||
|
||||
import { AlreadyInDBError } from '../errors/errors';
|
||||
import { GroupsService } from '../groups/groups.service';
|
||||
import { SpecialGroup } from '../groups/groups.special';
|
||||
|
||||
export async function setupSpecialGroups(
|
||||
app: NestExpressApplication,
|
||||
): Promise<void> {
|
||||
const groupService = app.get<GroupsService>(GroupsService);
|
||||
try {
|
||||
await groupService.createGroup(
|
||||
SpecialGroup.EVERYONE,
|
||||
SpecialGroup.EVERYONE,
|
||||
true,
|
||||
);
|
||||
await groupService.createGroup(
|
||||
SpecialGroup.LOGGED_IN,
|
||||
SpecialGroup.LOGGED_IN,
|
||||
true,
|
||||
);
|
||||
} catch (e) {
|
||||
if (e instanceof AlreadyInDBError) {
|
||||
// It's no problem if the special groups already exist
|
||||
return;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue