mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Max number of group per user is 3
This commit is contained in:
parent
da3d9cf76b
commit
93c6c4202a
1 changed files with 9 additions and 0 deletions
|
|
@ -17,6 +17,15 @@ export const createGroup = async (input: {
|
|||
}): Promise<[Group, Invite]> => {
|
||||
const [group, invite] = await AppDataSource.transaction<[Group, Invite]>(
|
||||
async (t) => {
|
||||
// Max number of groups a user can create
|
||||
const maxGroups = 3
|
||||
const groupCount = await getRepository(Group).countBy({
|
||||
createdBy: { id: input.admin.id },
|
||||
})
|
||||
if (groupCount >= maxGroups) {
|
||||
throw new Error('Max groups reached')
|
||||
}
|
||||
|
||||
const group = await t.getRepository(Group).save({
|
||||
name: input.name,
|
||||
createdBy: input.admin,
|
||||
|
|
|
|||
Loading…
Reference in a new issue