Merge branch 'refactor_community_auth' into refactor_community

This commit is contained in:
einhornimmond 2025-10-04 10:29:06 +02:00
commit f4c99572bd
3 changed files with 29 additions and 5 deletions

View File

@ -12,7 +12,6 @@ export class Community {
this.creationDate = dbCom.creationDate
this.uuid = dbCom.communityUuid
this.authenticatedAt = dbCom.authenticatedAt
// this.gmsApiKey = dbCom.gmsApiKey //
this.hieroTopicId = dbCom.hieroTopicId
}
@ -40,10 +39,6 @@ export class Community {
@Field(() => Date, { nullable: true })
authenticatedAt: Date | null
// gms api key should only seen by admins, they can use AdminCommunityView
// @Field(() => String, { nullable: true })
// gmsApiKey: string | null
@Field(() => String, { nullable: true })
hieroTopicId: string | null
}

View File

@ -227,6 +227,14 @@ describe('CommunityResolver', () => {
let foreignCom4: DbFederatedCommunity
beforeEach(async () => {
<<<<<<< HEAD
=======
jest.clearAllMocks()
await userFactory(testEnv, peterLustig)
// login as admin
await mutate({ mutation: login, variables: peterLoginData })
>>>>>>> refactor_community_auth
comHomeCom1 = DbCommunity.create()
comHomeCom1.foreign = false
comHomeCom1.url = 'http://localhost'

View File

@ -24,6 +24,24 @@ import { CONFIG } from '@/config'
@Resolver()
export class CommunityResolver {
<<<<<<< HEAD
=======
@Authorized([RIGHTS.COMMUNITIES])
@Query(() => [FederatedCommunity])
async getCommunities(): Promise<FederatedCommunity[]> {
const dbFederatedCommunities: DbFederatedCommunity[] = await DbFederatedCommunity.find({
order: {
foreign: 'ASC',
createdAt: 'DESC',
lastAnnouncedAt: 'DESC',
},
})
return dbFederatedCommunities.map(
(dbCom: DbFederatedCommunity) => new FederatedCommunity(dbCom),
)
}
>>>>>>> refactor_community_auth
@Authorized([RIGHTS.COMMUNITY_WITH_API_KEYS])
@Query(() => [AdminCommunityView])
async allCommunities(@Args() paginated: Paginated): Promise<AdminCommunityView[]> {
@ -95,7 +113,10 @@ export class CommunityResolver {
}
await DbCommunity.save(homeCom)
}
<<<<<<< HEAD
=======
>>>>>>> refactor_community_auth
return new AdminCommunityView(homeCom)
}
}