mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge pull request #3020 from gradido/federation-simplify-new-community-uuid
refactor(federation): simplify newCommunityUuid
This commit is contained in:
commit
9fc33356a9
@ -250,14 +250,11 @@ async function writeHomeCommunityEntry(pubKey: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const newCommunityUuid = async (): Promise<string> => {
|
const newCommunityUuid = async (): Promise<string> => {
|
||||||
let uuid: string
|
while (true) {
|
||||||
let countIds: number
|
const communityUuid = uuidv4()
|
||||||
do {
|
if ((await DbCommunity.count({ where: { communityUuid } })) === 0) {
|
||||||
uuid = uuidv4()
|
return communityUuid
|
||||||
countIds = await DbCommunity.count({ where: { communityUuid: uuid } })
|
}
|
||||||
if (countIds > 0) {
|
logger.info('CommunityUuid creation conflict...', communityUuid)
|
||||||
logger.info('CommunityUuid creation conflict...')
|
|
||||||
}
|
}
|
||||||
} while (countIds > 0)
|
|
||||||
return uuid
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user