mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import { Community as DbCommunity } from '@entity/Community'
|
|
|
|
export async function isHomeCommunity(communityIdentifier: string): Promise<boolean> {
|
|
const homeCommunity = await DbCommunity.findOne({
|
|
where: [
|
|
{ foreign: false, communityUuid: communityIdentifier },
|
|
{ foreign: false, name: communityIdentifier },
|
|
{ foreign: false, url: communityIdentifier },
|
|
],
|
|
})
|
|
if (homeCommunity) {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
}
|
|
|
|
export async function getCommunityUrl(communityIdentifier: string): Promise<string> {
|
|
const community = await DbCommunity.findOneOrFail({
|
|
where: [
|
|
{ communityUuid: communityIdentifier },
|
|
{ name: communityIdentifier },
|
|
{ url: communityIdentifier },
|
|
],
|
|
})
|
|
return community.url
|
|
}
|
|
|
|
export async function isCommunityAuthenticated(communityIdentifier: string): Promise<boolean> {
|
|
const community = await DbCommunity.findOne({
|
|
where: [
|
|
{ communityUuid: communityIdentifier },
|
|
{ name: communityIdentifier },
|
|
{ url: communityIdentifier },
|
|
],
|
|
})
|
|
if (community?.authenticatedAt) {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
}
|
|
|
|
export async function getCommunityName(communityIdentifier: string): Promise<string> {
|
|
const community = await DbCommunity.findOne({
|
|
where: [{ communityUuid: communityIdentifier }, { url: communityIdentifier }],
|
|
})
|
|
if (community?.name) {
|
|
return community.name
|
|
} else {
|
|
return ''
|
|
}
|
|
}
|
|
|
|
export async function getCommunity(communityUuid: string): Promise<DbCommunity | null> {
|
|
return await DbCommunity.findOne({
|
|
where: [{ communityUuid }],
|
|
})
|
|
}
|