Skip to content

Commit

Permalink
Merge pull request #4177 from alkem-io/develop
Browse files Browse the repository at this point in the history
MemeberJoined
  • Loading branch information
valentinyanakiev authored Jun 28, 2024
2 parents 2dd9774 + c1291f2 commit 40bf904
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/services/adapters/activity-adapter/activity.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 11 additions & 6 deletions src/services/api/activity-log/activity.log.builder.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/services/api/activity-log/activity.log.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -27,6 +28,7 @@ import { UrlGeneratorModule } from '@services/infrastructure/url-generator';
ActivityModule,
CollaborationModule,
UserModule,
ContributorLookupModule,
CommunityModule,
CalloutModule,
PostModule,
Expand Down
4 changes: 3 additions & 1 deletion src/services/api/activity-log/activity.log.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -133,7 +135,7 @@ export class ActivityLogService {
const activityBuilder: IActivityLogBuilder =
new ActivityLogBuilderService(
activityLogEntryBase,
this.userService,
this.contributorLookupService,
this.calloutService,
this.postService,
this.whiteboardService,
Expand Down
Original file line number Diff line number Diff line change
@@ -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],
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,19 @@ export class ContributorLookupService {
return contributor;
}

async getContributorOrFail(
contributorID: string,
options?: FindOneOptions<IContributor>
): Promise<IContributor | never> {
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
Expand Down

0 comments on commit 40bf904

Please sign in to comment.