diff --git a/package-lock.json b/package-lock.json index 3f7dc9047d..8d46a17293 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "alkemio-server", - "version": "0.82.4", + "version": "0.82.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "alkemio-server", - "version": "0.82.4", + "version": "0.82.5", "license": "EUPL-1.2", "dependencies": { "@alkemio/matrix-adapter-lib": "^0.3.6", diff --git a/package.json b/package.json index 178e406a25..fdf8d4fdc0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "alkemio-server", - "version": "0.82.4", + "version": "0.82.5", "description": "Alkemio server, responsible for managing the shared Alkemio platform", "author": "Alkemio Foundation", "private": false, diff --git a/src/services/adapters/activity-adapter/activity.adapter.ts b/src/services/adapters/activity-adapter/activity.adapter.ts index 9cf8ecee68..2b3a72f9bd 100644 --- a/src/services/adapters/activity-adapter/activity.adapter.ts +++ b/src/services/adapters/activity-adapter/activity.adapter.ts @@ -329,7 +329,7 @@ export class ActivityAdapter { const activity = await this.activityService.createActivity({ triggeredBy: eventData.triggeredBy, collaborationID, - resourceID: eventData.contributor.id, // the user that joined + resourceID: eventData.contributor.id, // the contributor that joined parentID: community.id, // the community that was joined description: description, type: eventType, diff --git a/src/services/api/activity-log/activity.log.builder.service.ts b/src/services/api/activity-log/activity.log.builder.service.ts index c13fd22d1f..c2af57f60f 100644 --- a/src/services/api/activity-log/activity.log.builder.service.ts +++ b/src/services/api/activity-log/activity.log.builder.service.ts @@ -8,7 +8,6 @@ import { IActivityLogEntryChallengeCreated } from '@services/api/activity-log/dt import { IActivityLogEntryOpportunityCreated } from '@services/api/activity-log/dto/activity.log.dto.entry.subsubspace.created'; import { IActivityLogEntryCalloutPostComment } from '@services/api/activity-log/dto/activity.log.dto.entry.callout.post.comment'; import { IActivityLogEntryCalloutDiscussionComment } from '@services/api/activity-log/dto/activity.log.dto.entry.callout.discussion.comment'; -import { UserService } from '@domain/community/user/user.service'; import { CalloutService } from '@domain/collaboration/callout/callout.service'; import { PostService } from '@domain/collaboration/post/post.service'; import { WhiteboardService } from '@domain/common/whiteboard/whiteboard.service'; @@ -30,11 +29,12 @@ import { EntityManager } from 'typeorm'; import { Space } from '@domain/space/space/space.entity'; import { EntityNotFoundException } from '@common/exceptions/entity.not.found.exception'; import { LogContext } from '@common/enums/logging.context'; +import { ContributorLookupService } from '@services/infrastructure/contributor-lookup/contributor.lookup.service'; export default class ActivityLogBuilderService implements IActivityLogBuilder { constructor( private readonly activityLogEntryBase: IActivityLogEntry, - private readonly userService: UserService, + private readonly contributorLookupService: ContributorLookupService, private readonly calloutService: CalloutService, private readonly postService: PostService, private readonly whiteboardService: WhiteboardService, @@ -53,13 +53,18 @@ export default class ActivityLogBuilderService implements IActivityLogBuilder { const community = await this.communityService.getCommunityOrFail( rawActivity.parentID ); - const userJoining = await this.userService.getUserOrFail( - rawActivity.resourceID - ); + const contributorJoining = + await this.contributorLookupService.getContributorOrFail( + rawActivity.resourceID + ); + + const contributorType = + this.contributorLookupService.getContributorType(contributorJoining); const activityMemberJoined: IActivityLogEntryMemberJoined = { ...this.activityLogEntryBase, community: community, - user: userJoining, + contributor: contributorJoining, + contributorType: contributorType, communityType: `${community.type}`, }; return activityMemberJoined; diff --git a/src/services/api/activity-log/activity.log.module.ts b/src/services/api/activity-log/activity.log.module.ts index 5f9a8e50d1..cb1aa6d8bd 100644 --- a/src/services/api/activity-log/activity.log.module.ts +++ b/src/services/api/activity-log/activity.log.module.ts @@ -19,6 +19,7 @@ import { CalendarEventModule } from '@domain/timeline/event/event.module'; import { SpaceModule } from '@domain/space/space/space.module'; import { LinkModule } from '@domain/collaboration/link/link.module'; import { UrlGeneratorModule } from '@services/infrastructure/url-generator'; +import { ContributorLookupModule } from '@services/infrastructure/contributor-lookup/contributor.lookup.module'; @Module({ imports: [ @@ -27,6 +28,7 @@ import { UrlGeneratorModule } from '@services/infrastructure/url-generator'; ActivityModule, CollaborationModule, UserModule, + ContributorLookupModule, CommunityModule, CalloutModule, PostModule, diff --git a/src/services/api/activity-log/activity.log.service.ts b/src/services/api/activity-log/activity.log.service.ts index d2bffcd055..28c14d4b9b 100644 --- a/src/services/api/activity-log/activity.log.service.ts +++ b/src/services/api/activity-log/activity.log.service.ts @@ -21,11 +21,13 @@ import { LinkService } from '@domain/collaboration/link/link.service'; import { UrlGeneratorService } from '@services/infrastructure/url-generator/url.generator.service'; import { EntityManager } from 'typeorm/entity-manager/EntityManager'; import { InjectEntityManager } from '@nestjs/typeorm'; +import { ContributorLookupService } from '@services/infrastructure/contributor-lookup/contributor.lookup.service'; export class ActivityLogService { constructor( private activityService: ActivityService, private userService: UserService, + private contributorLookupService: ContributorLookupService, private calloutService: CalloutService, private postService: PostService, private whiteboardService: WhiteboardService, @@ -133,7 +135,7 @@ export class ActivityLogService { const activityBuilder: IActivityLogBuilder = new ActivityLogBuilderService( activityLogEntryBase, - this.userService, + this.contributorLookupService, this.calloutService, this.postService, this.whiteboardService, diff --git a/src/services/api/activity-log/dto/activity.log.dto.entry.member.joined.interface.ts b/src/services/api/activity-log/dto/activity.log.dto.entry.member.joined.interface.ts index 0a91fbf837..27756a2b09 100644 --- a/src/services/api/activity-log/dto/activity.log.dto.entry.member.joined.interface.ts +++ b/src/services/api/activity-log/dto/activity.log.dto.entry.member.joined.interface.ts @@ -1,8 +1,9 @@ import { ICommunity } from '@domain/community/community'; -import { IUser } from '@domain/community/user/user.interface'; import { Field, ObjectType } from '@nestjs/graphql'; import { IActivityLogEntryBase } from './activity.log.dto.entry.base.interface'; import { IActivityLogEntry } from './activity.log.entry.interface'; +import { CommunityContributorType } from '@common/enums/community.contributor.type'; +import { IContributor } from '@domain/community/contributor/contributor.interface'; @ObjectType('ActivityLogEntryMemberJoined', { implements: () => [IActivityLogEntry], @@ -11,11 +12,17 @@ export abstract class IActivityLogEntryMemberJoined extends IActivityLogEntryBase implements IActivityLogEntry { - @Field(() => IUser, { + @Field(() => IContributor, { nullable: false, - description: 'The User that joined the Community.', + description: 'The Contributor that joined the Community.', }) - user!: IUser; + contributor!: IContributor; + + @Field(() => CommunityContributorType, { + nullable: false, + description: 'The type of the Contributor that joined the Community.', + }) + contributorType!: CommunityContributorType; @Field(() => String, { nullable: false, diff --git a/src/services/infrastructure/contributor-lookup/contributor.lookup.service.ts b/src/services/infrastructure/contributor-lookup/contributor.lookup.service.ts index d142cc2802..352b9885ed 100644 --- a/src/services/infrastructure/contributor-lookup/contributor.lookup.service.ts +++ b/src/services/infrastructure/contributor-lookup/contributor.lookup.service.ts @@ -253,6 +253,19 @@ export class ContributorLookupService { return contributor; } + async getContributorOrFail( + contributorID: string, + options?: FindOneOptions + ): Promise { + const contributor = await this.getContributor(contributorID, options); + if (!contributor) + throw new EntityNotFoundException( + `Unable to find Contributor with ID: ${contributorID}`, + LogContext.COMMUNITY + ); + return contributor; + } + private async getCredentialsByTypeHeldByAgent( agentID: string, credentialType: AuthorizationCredential