Skip to content

Commit

Permalink
Merge pull request #4170 from alkem-io/develop
Browse files Browse the repository at this point in the history
Release: Virtual Contributor, Platform Invitations, Invitations with Roles
  • Loading branch information
valentinyanakiev authored Jun 28, 2024
2 parents 4932c37 + 1a6b951 commit 77d851e
Show file tree
Hide file tree
Showing 125 changed files with 4,210 additions and 1,681 deletions.
3,214 changes: 2,823 additions & 391 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "alkemio-server",
"version": "0.82.1",
"version": "0.82.2",
"description": "Alkemio server, responsible for managing the shared Alkemio platform",
"author": "Alkemio Foundation",
"private": false,
Expand Down Expand Up @@ -52,7 +52,7 @@
},
"dependencies": {
"@alkemio/matrix-adapter-lib": "^0.3.6",
"@alkemio/notifications-lib": "^0.8.5",
"@alkemio/notifications-lib": "^0.9.3",
"@apollo/server": "^4.10.2",
"@elastic/elasticsearch": "^8.4.0",
"@golevelup/nestjs-rabbitmq": "^5.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,3 @@ export const CREDENTIAL_RULE_DOCUMENT_CREATED_BY =
'credentialRule-documentCreatedBy';
export const CREDENTIAL_RULE_LIBRARY_INNOVATION_PACK_PROVIDER_ADMIN =
'credentialRule-libraryInnovationPackProvider';
export const CREDENTIAL_RULE_VIRTUAL_CONTRIBUTOR_CREATED_BY =
'credentialRule-virtualContributorCreatedBy';
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export const CREDENTIAL_RULE_TYPES_VC_GLOBAL_COMMUNITY_READ =
'credentialRuleTypes-vcGlobalCommunityRead';
export const CREDENTIAL_RULE_TYPES_VC_GLOBAL_SUPPORT_MANAGE =
'credentialRuleTypes-vcGlobalSupportManage';
export const CREDENTIAL_RULE_TYPES_VC_PROVIDER =
'credentialRuleTypes-vcProvider';
export const CREDENTIAL_RULE_TYPES_VC_GLOBAL_ADMINS =
'credentialRuleTypes-vcGlobalAdmins';
export const CREDENTIAL_RULE_TYPES_PLATFORM_GLOBAL_ADMINS =
Expand Down
2 changes: 2 additions & 0 deletions src/common/enums/authorization.credential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export enum AuthorizationCredential {
// Library related credentials
INNOVATION_PACK_PROVIDER = 'innovation-pack-provider',

// Roles to allow easier management of users
BETA_TESTER = 'beta-tester',
VC_CAMPAIGN = 'vc-campaign',
}

registerEnumType(AuthorizationCredential, {
Expand Down
3 changes: 2 additions & 1 deletion src/common/enums/logging.context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export enum LogContext {
GEO = 'geo',
CALENDAR = 'calendar',
INNOVATION_HUB = 'innovation-hub',
VIRTUAL_CONTRIBUTOR_ENGINE = 'virtual-contributor-engine',
CHAT_GUIDANCE = 'chat-guidance',
CHAT_GUIDANCE_REPORTER = 'chat-guidance-reporter',
TAGSET = 'tagset',
Expand All @@ -63,6 +62,8 @@ export enum LogContext {
LOCAL_STORAGE = 'local-storage',
INNOVATION_FLOW = 'innovation-flow',
FILE_INTEGRATION = 'file-integration',
VIRTUAL_CONTRIBUTOR = 'virtual-contributor',
AI_SERVER = 'ai-server',
AI_PERSONA_SERVICE = 'ai-persona-service',
AI_PERSONA_SERVICE_ENGINE = 'ai-persona-service-engine',
}
1 change: 1 addition & 0 deletions src/common/enums/platform.role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum PlatformRole {
COMMUNITY_READER = 'community-reader',
SPACES_READER = 'spaces-reader',
BETA_TESTER = 'beta-tester',
VC_CAMPAIGN = 'vc-campaign',
}

registerEnumType(PlatformRole, {
Expand Down
4 changes: 2 additions & 2 deletions src/core/validation/handlers/base/base.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import {
UpdateDocumentInput,
} from '@domain/storage/document';
import { VisualUploadImageInput } from '@domain/common/visual/dto/visual.dto.upload.image';
import { CreateInvitationUserByEmailOnCommunityInput } from '@domain/community/community/dto/community.dto.invite.external.user';
import { UpdateInnovationFlowInput } from '@domain/collaboration/innovation-flow/dto';
import {
CreateCalloutFramingInput,
Expand Down Expand Up @@ -84,6 +83,7 @@ import { UpdateAccountDefaultsInput } from '@domain/space/account/dto/account.dt
import { UpdateCommunityGuidelinesInput } from '@domain/community/community-guidelines/dto/community.guidelines.dto.update';
import { CreateInvitationForContributorsOnCommunityInput } from '@domain/community/community/dto/community.dto.invite.contributor';
import { ForumCreateDiscussionInput } from '@platform/forum/dto/forum.dto.create.discussion';
import { CreatePlatformInvitationOnCommunityInput } from '@domain/community/community/dto/community.dto.platform.invitation.community';

export class BaseHandler extends AbstractHandler {
public async handle(
Expand Down Expand Up @@ -150,7 +150,7 @@ export class BaseHandler extends AbstractHandler {
VisualUploadImageInput,
CommunityApplyInput,
CreateInvitationForContributorsOnCommunityInput,
CreateInvitationUserByEmailOnCommunityInput,
CreatePlatformInvitationOnCommunityInput,
ForumCreateDiscussionInput,
SendMessageOnCalloutInput,
CreateCalloutOnCollaborationInput,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { AuthorizationModule } from '@core/authorization/authorization.module';
import { WhiteboardModule } from '@domain/common/whiteboard/whiteboard.module';
import { NamingModule } from '@services/infrastructure/naming/naming.module';
import { PostModule } from '../post/post.module';
import { UserLookupModule } from '@services/infrastructure/user-lookup/user.lookup.module';
import { ContributorLookupModule } from '@services/infrastructure/contributor-lookup/contributor.lookup.module';
import { CommunityPolicyModule } from '@domain/community/community-policy/community.policy.module';
import { LinkModule } from '../link/link.module';

Expand All @@ -21,7 +21,7 @@ import { LinkModule } from '../link/link.module';
PostModule,
NamingModule,
LinkModule,
UserLookupModule,
ContributorLookupModule,
CommunityPolicyModule,
TypeOrmModule.forFeature([CalloutContribution]),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IWhiteboard } from '@domain/common/whiteboard/whiteboard.interface';
import { CalloutContributionService } from './callout.contribution.service';
import { IPost } from '../post/post.interface';
import { IUser } from '@domain/community/user/user.interface';
import { UserLookupService } from '@services/infrastructure/user-lookup/user.lookup.service';
import { ContributorLookupService } from '@services/infrastructure/contributor-lookup/contributor.lookup.service';
import { EntityNotFoundException } from '@common/exceptions/entity.not.found.exception';
import { LoggerService } from '@nestjs/common';
import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
Expand All @@ -18,7 +18,7 @@ import { ILink } from '../link/link.interface';
export class CalloutContributionResolverFields {
constructor(
private calloutContributionService: CalloutContributionService,
private userLookupService: UserLookupService,
private userLookupService: ContributorLookupService,
@Inject(WINSTON_MODULE_NEST_PROVIDER)
private readonly logger: LoggerService
) {}
Expand Down
4 changes: 2 additions & 2 deletions src/domain/collaboration/callout/callout.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { MessagingModule } from '@domain/communication/messaging/messaging.modul
import { ContributionReporterModule } from '@services/external/elasticsearch/contribution-reporter';
import { RoomModule } from '@domain/communication/room/room.module';
import { ReferenceModule } from '@domain/common/reference/reference.module';
import { UserLookupModule } from '@services/infrastructure/user-lookup/user.lookup.module';
import { ContributorLookupModule } from '@services/infrastructure/contributor-lookup/contributor.lookup.module';
import { StorageAggregatorResolverModule } from '@services/infrastructure/storage-aggregator-resolver/storage.aggregator.resolver.module';
import { CalloutFramingModule } from '../callout-framing/callout.framing.module';
import { CalloutContributionDefaultsModule } from '../callout-contribution-defaults/callout.contribution.defaults.module';
Expand All @@ -36,7 +36,7 @@ import { PostModule } from '../post/post.module';
RoomModule,
CommunityPolicyModule,
EntityResolverModule,
UserLookupModule,
ContributorLookupModule,
NamingModule,
MessagingModule,
ReferenceModule,
Expand Down
4 changes: 2 additions & 2 deletions src/domain/collaboration/callout/callout.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { RoomService } from '@domain/communication/room/room.service';
import { RoomType } from '@common/enums/room.type';
import { IRoom } from '@domain/communication/room/room.interface';
import { ITagsetTemplate } from '@domain/common/tagset-template';
import { UserLookupService } from '@services/infrastructure/user-lookup/user.lookup.service';
import { ContributorLookupService } from '@services/infrastructure/contributor-lookup/contributor.lookup.service';
import { CalloutFramingService } from '../callout-framing/callout.framing.service';
import { ICalloutFraming } from '../callout-framing/callout.framing.interface';
import { CalloutContributionDefaultsService } from '../callout-contribution-defaults/callout.contribution.defaults.service';
Expand All @@ -47,7 +47,7 @@ export class CalloutService {
private authorizationPolicyService: AuthorizationPolicyService,
private namingService: NamingService,
private roomService: RoomService,
private userLookupService: UserLookupService,
private userLookupService: ContributorLookupService,
private calloutFramingService: CalloutFramingService,
private contributionDefaultsService: CalloutContributionDefaultsService,
private contributionPolicyService: CalloutContributionPolicyService,
Expand Down
4 changes: 2 additions & 2 deletions src/domain/collaboration/post/post.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { PostAuthorizationService } from './post.service.authorization';
import { CommunityPolicyModule } from '@domain/community/community-policy/community.policy.module';
import { ProfileModule } from '@domain/common/profile/profile.module';
import { RoomModule } from '@domain/communication/room/room.module';
import { UserLookupModule } from '@services/infrastructure/user-lookup/user.lookup.module';
import { ContributorLookupModule } from '@services/infrastructure/contributor-lookup/contributor.lookup.module';

@Module({
imports: [
Expand All @@ -20,7 +20,7 @@ import { UserLookupModule } from '@services/infrastructure/user-lookup/user.look
RoomModule,
CommunityPolicyModule,
VisualModule,
UserLookupModule,
ContributorLookupModule,
ProfileModule,
TypeOrmModule.forFeature([Post]),
],
Expand Down
4 changes: 2 additions & 2 deletions src/domain/collaboration/post/post.resolver.fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import { Loader } from '@core/dataloader/decorators';
import { ProfileLoaderCreator } from '@core/dataloader/creators';
import { ILoader } from '@core/dataloader/loader.interface';
import { Post } from '@domain/collaboration/post/post.entity';
import { UserLookupService } from '@services/infrastructure/user-lookup/user.lookup.service';
import { ContributorLookupService } from '@services/infrastructure/contributor-lookup/contributor.lookup.service';

@Resolver(() => IPost)
export class PostResolverFields {
constructor(
@Inject(WINSTON_MODULE_NEST_PROVIDER)
private readonly logger: LoggerService,
private userLookupService: UserLookupService
private userLookupService: ContributorLookupService
) {}

@ResolveField('createdBy', () => IUser, {
Expand Down
10 changes: 7 additions & 3 deletions src/domain/communication/communication/communication.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,18 @@ export class CommunicationService {
return true;
}

async addUserToCommunications(
async addContributorToCommunications(
communication: ICommunication,
communicationUserID: string
contributorCommunicationID: string
): Promise<boolean> {
if (!contributorCommunicationID || contributorCommunicationID === '') {
// no communication ID to manage, just return
return true;
}
const communicationRoomIDs = await this.getRoomsUsed(communication);
await this.communicationAdapter.grantUserAccessToRooms(
communicationRoomIDs,
communicationUserID
contributorCommunicationID
);

return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Field, ObjectType } from '@nestjs/graphql';
import { ISource } from '@services/api/chat-guidance/dto/chat.guidance.query.result.dto';
import { IAnswerToQuestionSource } from './message.answer.to.question.source.interface';

@ObjectType('AiPersonaResult')
export abstract class IAiPersonaQuestionResult {
@ObjectType('MessageAnswerQuestion', {
description: 'A detailed answer to a question, typically from an AI service.',
})
export class IMessageAnswerToQuestion {
@Field(() => String, {
nullable: true,
description: 'The id of the answer; null if an error was returned',
Expand All @@ -15,11 +17,11 @@ export abstract class IAiPersonaQuestionResult {
})
question!: string;

@Field(() => [ISource], {
@Field(() => [IAnswerToQuestionSource], {
nullable: true,
description: 'The sources used to answer the question',
})
sources?: ISource[];
sources?: IAnswerToQuestionSource[];

@Field(() => String, {
nullable: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Module } from '@nestjs/common';
import { ContributorLookupModule } from '@services/infrastructure/contributor-lookup/contributor.lookup.module';
import { TypeOrmModule } from '@nestjs/typeorm';
import { VirtualContributor } from '@domain/community/virtual-contributor';

@Module({
imports: [
ContributorLookupModule,
TypeOrmModule.forFeature([VirtualContributor]),
],
providers: [],
exports: [],
})
export class MessageAnswerToQuestionModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Field, ObjectType } from '@nestjs/graphql';

@ObjectType('MessageAnswerToQuestionSource', {
description: 'A source used in a detailed answer to a question.',
})
export class IAnswerToQuestionSource {
@Field(() => String, {
nullable: true,
description: 'The URI of the source',
})
uri!: string;

@Field(() => String, {
nullable: true,
description: 'The title of the source',
})
title!: string;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Module } from '@nestjs/common';
import { MessageReactionResolverFields } from './message.reaction.resolver.fields';
import { UserLookupModule } from '@services/infrastructure/user-lookup/user.lookup.module';
import { ContributorLookupModule } from '@services/infrastructure/contributor-lookup/contributor.lookup.module';

@Module({
imports: [UserLookupModule],
imports: [ContributorLookupModule],
providers: [MessageReactionResolverFields],
exports: [MessageReactionResolverFields],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { EntityNotFoundException } from '@common/exceptions';
import { Inject, LoggerService } from '@nestjs/common';
import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
import { IMessageReaction } from './message.reaction.interface';
import { UserLookupService } from '@services/infrastructure/user-lookup/user.lookup.service';
import { ContributorLookupService } from '@services/infrastructure/contributor-lookup/contributor.lookup.service';

@Resolver(() => IMessageReaction)
export class MessageReactionResolverFields {
constructor(
@Inject(WINSTON_MODULE_NEST_PROVIDER)
private readonly logger: LoggerService,
private userLookupService: UserLookupService
private userLookupService: ContributorLookupService
) {}

@ResolveField('sender', () => IUser, {
Expand Down
12 changes: 8 additions & 4 deletions src/domain/communication/message/message.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { Module } from '@nestjs/common';
import { MessageResolverFields } from './message.resolver.fields';
import { UserLookupModule } from '@services/infrastructure/user-lookup/user.lookup.module';
import { ContributorLookupModule } from '@services/infrastructure/contributor-lookup/contributor.lookup.module';
import { TypeOrmModule } from '@nestjs/typeorm';
import { VirtualContributor } from '@domain/community/virtual-contributor';
import { MessageService } from './message.service';

@Module({
imports: [UserLookupModule, TypeOrmModule.forFeature([VirtualContributor])],
providers: [MessageResolverFields],
exports: [MessageResolverFields],
imports: [
ContributorLookupModule,
TypeOrmModule.forFeature([VirtualContributor]),
],
providers: [MessageResolverFields, MessageService],
exports: [MessageResolverFields, MessageService],
})
export class MessageModule {}
4 changes: 2 additions & 2 deletions src/domain/communication/message/message.resolver.fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { LogContext } from '@common/enums/logging.context';
import { EntityNotFoundException } from '@common/exceptions';
import { Inject, LoggerService } from '@nestjs/common';
import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
import { UserLookupService } from '@services/infrastructure/user-lookup/user.lookup.service';
import { ContributorLookupService } from '@services/infrastructure/contributor-lookup/contributor.lookup.service';
import { VirtualContributor } from '@domain/community/virtual-contributor';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
Expand All @@ -15,7 +15,7 @@ export class MessageResolverFields {
constructor(
@Inject(WINSTON_MODULE_NEST_PROVIDER)
private readonly logger: LoggerService,
private userLookupService: UserLookupService,
private userLookupService: ContributorLookupService,
@InjectRepository(VirtualContributor)
private virtualContributorRepository: Repository<VirtualContributor>
) {}
Expand Down
31 changes: 31 additions & 0 deletions src/domain/communication/message/message.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { LogContext } from '@common/enums/logging.context';
import { IMessageAnswerToQuestion } from '../message.answer.to.question/message.answer.to.question.interface';
import { LoggerService } from '@nestjs/common/services/logger.service';
import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
import { Inject, Injectable } from '@nestjs/common';

@Injectable()
export class MessageService {
constructor(
@Inject(WINSTON_MODULE_NEST_PROVIDER) private readonly logger: LoggerService
) {}

public convertAnswerToSimpleMessage(
answerToQuestion: IMessageAnswerToQuestion
): string {
this.logger.verbose?.(
`Converting answer to simple message: ${JSON.stringify(
answerToQuestion
)}`,
LogContext.COMMUNICATION
);
let answer = answerToQuestion.answer;

if (answerToQuestion.sources) {
answer = `${answer}\n${answerToQuestion.sources
.map(({ title, uri }) => `- [${title}](${uri})`)
.join('\n')}`;
}
return answer;
}
}
2 changes: 2 additions & 0 deletions src/domain/communication/room/room.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { RoomServiceEvents } from './room.service.events';
import { RoomEventResolverSubscription } from './room.event.resolver.subscription';
import { SubscriptionServiceModule } from '@services/subscriptions/subscription-service';
import { VirtualContributorModule } from '@domain/community/virtual-contributor/virtual.contributor.module';
import { MessageModule } from '../message/message.module';

@Module({
imports: [
Expand All @@ -31,6 +32,7 @@ import { VirtualContributorModule } from '@domain/community/virtual-contributor/
RoomModule,
CommunicationAdapterModule,
MessagingModule,
MessageModule,
VirtualContributorModule,
TypeOrmModule.forFeature([Room]),
SubscriptionServiceModule,
Expand Down
Loading

0 comments on commit 77d851e

Please sign in to comment.