mirror of
https://github.com/IT4Change/gradido.git
synced 2026-04-06 01:25:28 +00:00
add call for getting authorized communities
This commit is contained in:
parent
b023fd98b6
commit
14f7e91fdc
@ -2,7 +2,7 @@ import { Paginated } from '@arg/Paginated'
|
||||
import { EditCommunityInput } from '@input/EditCommunityInput'
|
||||
import { AdminCommunityView } from '@model/AdminCommunityView'
|
||||
import { Community } from '@model/Community'
|
||||
import { Community as DbCommunity, getHomeCommunity, getReachableCommunities } from 'database'
|
||||
import { Community as DbCommunity, getAuthorizedCommunities, getHomeCommunity, getReachableCommunities } from 'database'
|
||||
import { updateAllDefinedAndChanged } from 'shared'
|
||||
import { Arg, Args, Authorized, Mutation, Query, Resolver } from 'type-graphql'
|
||||
import { RIGHTS } from '@/auth/RIGHTS'
|
||||
@ -34,6 +34,17 @@ export class CommunityResolver {
|
||||
return dbCommunities.map((dbCom: DbCommunity) => new Community(dbCom))
|
||||
}
|
||||
|
||||
@Authorized([RIGHTS.COMMUNITIES])
|
||||
@Query(() => [Community])
|
||||
async authorizedCommunities(): Promise<Community[]> {
|
||||
const dbCommunities: DbCommunity[] = await getAuthorizedCommunities({
|
||||
// order by
|
||||
foreign: 'ASC', // home community first
|
||||
name: 'ASC',
|
||||
})
|
||||
return dbCommunities.map((dbCom: DbCommunity) => new Community(dbCom))
|
||||
}
|
||||
|
||||
@Authorized([RIGHTS.COMMUNITIES])
|
||||
@Query(() => Community)
|
||||
async communityByIdentifier(
|
||||
|
||||
@ -84,7 +84,7 @@ export async function getReachableCommunities(
|
||||
federatedCommunities: {
|
||||
verifiedAt: MoreThanOrEqual(new Date(Date.now() - authenticationTimeoutMs)),
|
||||
},
|
||||
},
|
||||
}, // or
|
||||
{ foreign: false },
|
||||
],
|
||||
order,
|
||||
@ -99,3 +99,17 @@ export async function getNotReachableCommunities(
|
||||
order,
|
||||
})
|
||||
}
|
||||
|
||||
// return the home community and all communities which had at least once make it through the first handshake
|
||||
export async function getAuthorizedCommunities(
|
||||
order?: FindOptionsOrder<DbCommunity>,
|
||||
): Promise<DbCommunity[]>
|
||||
{
|
||||
return await DbCommunity.find({
|
||||
where: [
|
||||
{ authenticatedAt: Not(IsNull()) }, // or
|
||||
{ foreign: false }
|
||||
],
|
||||
order
|
||||
})
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user