From d4899750375815afab351f57bc4647f238530dda Mon Sep 17 00:00:00 2001 From: Alessandro Magionami Date: Fri, 11 Oct 2024 15:49:38 +0200 Subject: [PATCH] Activitystream IoC 4 addCommitCreatedActivity (#3239) * chore(activitystream): addStreamUpdatedActivity refactor multi region * chore(activitystream): addStreamAccessRequestedActivity refactor multiregion * chore(activitystream): addStreamAccessRequestDeclinedActivity refactor multiregion * chore(activitystream): onUserCreated refactor multiregion * chore(activitystream): addCommitCreatedActivity refactor multiregion * chore(activitystream): fix types --- .../activitystream/domain/operations.ts | 17 +++- .../activitystream/services/commitActivity.ts | 97 +++++++++++-------- .../modules/cli/commands/download/commit.ts | 9 +- .../modules/cli/commands/download/project.ts | 7 +- .../comments/tests/comments.graph.spec.js | 11 ++- .../modules/comments/tests/comments.spec.js | 11 ++- .../modules/core/graph/resolvers/commits.js | 13 ++- .../modules/core/graph/resolvers/versions.ts | 11 ++- .../core/services/commit/management.ts | 4 +- .../modules/core/tests/branches.spec.js | 11 ++- .../server/modules/core/tests/commits.spec.js | 6 +- .../server/modules/core/tests/streams.spec.ts | 7 +- .../server/modules/core/tests/users.spec.js | 11 ++- .../server/modules/cross-server-sync/index.ts | 7 +- .../modules/shared/utils/subscriptions.ts | 1 + .../server/modules/stats/tests/stats.spec.ts | 7 +- .../test/speckle-helpers/commitHelper.ts | 9 +- 17 files changed, 157 insertions(+), 82 deletions(-) diff --git a/packages/server/modules/activitystream/domain/operations.ts b/packages/server/modules/activitystream/domain/operations.ts index b9da302b58..0a11fdf57d 100644 --- a/packages/server/modules/activitystream/domain/operations.ts +++ b/packages/server/modules/activitystream/domain/operations.ts @@ -8,10 +8,15 @@ import { StreamScopeActivity } from '@/modules/activitystream/helpers/types' import { + CommitCreateInput, ProjectUpdateInput, StreamUpdateInput } from '@/modules/core/graph/generated/graphql' -import { StreamAclRecord, StreamRecord } from '@/modules/core/helpers/types' +import { + CommitRecord, + StreamAclRecord, + StreamRecord +} from '@/modules/core/helpers/types' export type GetActivity = ( streamId: string, @@ -197,3 +202,13 @@ export type AddStreamAccessRequestDeclinedActivity = (params: { requesterId: string declinerId: string }) => Promise + +export type AddCommitCreatedActivity = (params: { + commitId: string + streamId: string + userId: string + input: CommitCreateInput + branchName: string + modelId: string + commit: CommitRecord +}) => Promise diff --git a/packages/server/modules/activitystream/services/commitActivity.ts b/packages/server/modules/activitystream/services/commitActivity.ts index 5815aaa423..82def7a7da 100644 --- a/packages/server/modules/activitystream/services/commitActivity.ts +++ b/packages/server/modules/activitystream/services/commitActivity.ts @@ -1,6 +1,7 @@ import { ActionTypes, ResourceTypes } from '@/modules/activitystream/helpers/types' import { CommitSubscriptions as CommitPubsubEvents, + PublishSubscription, pubsub } from '@/modules/shared/utils/subscriptions' import { @@ -15,53 +16,65 @@ import { ProjectSubscriptions, publish } from '@/modules/shared/utils/subscripti import { has } from 'lodash' import { saveActivityFactory } from '@/modules/activitystream/repositories' import { db } from '@/db/knex' +import { + AddCommitCreatedActivity, + SaveActivity +} from '@/modules/activitystream/domain/operations' /** * Save "new commit created" activity item */ -export async function addCommitCreatedActivity(params: { - commitId: string - streamId: string - userId: string - input: CommitCreateInput - branchName: string - modelId: string - commit: CommitRecord -}) { - const { commitId, input, streamId, userId, branchName, commit } = params - await Promise.all([ - saveActivityFactory({ db })({ - streamId, - resourceType: ResourceTypes.Commit, - resourceId: commitId, - actionType: ActionTypes.Commit.Create, - userId, - info: { - id: commitId, - commit: { - ...input, - projectId: streamId, - modelId: params.modelId, - versionId: commit.id +export const addCommitCreatedActivityFactory = + ({ + saveActivity, + publish + }: { + saveActivity: SaveActivity + publish: PublishSubscription + }): AddCommitCreatedActivity => + async (params: { + commitId: string + streamId: string + userId: string + input: CommitCreateInput + branchName: string + modelId: string + commit: CommitRecord + }) => { + const { commitId, input, streamId, userId, branchName, commit } = params + await Promise.all([ + saveActivity({ + streamId, + resourceType: ResourceTypes.Commit, + resourceId: commitId, + actionType: ActionTypes.Commit.Create, + userId, + info: { + id: commitId, + commit: { + ...input, + projectId: streamId, + modelId: params.modelId, + versionId: commit.id + } + }, + message: `Commit created on branch ${branchName}: ${commitId} (${input.message})` + }), + publish(CommitPubsubEvents.CommitCreated, { + commitCreated: { ...input, id: commitId, authorId: userId }, + streamId + }), + publish(ProjectSubscriptions.ProjectVersionsUpdated, { + projectId: streamId, + projectVersionsUpdated: { + id: commit.id, + version: commit, + type: ProjectVersionsUpdatedMessageType.Created, + modelId: null } - }, - message: `Commit created on branch ${branchName}: ${commitId} (${input.message})` - }), - pubsub.publish(CommitPubsubEvents.CommitCreated, { - commitCreated: { ...input, id: commitId, authorId: userId }, - streamId - }), - publish(ProjectSubscriptions.ProjectVersionsUpdated, { - projectId: streamId, - projectVersionsUpdated: { - id: commit.id, - version: commit, - type: ProjectVersionsUpdatedMessageType.Created, - modelId: null - } - }) - ]) -} + }) + ]) + } const isOldVersionUpdateInput = ( i: CommitUpdateInput | UpdateVersionInput diff --git a/packages/server/modules/cli/commands/download/commit.ts b/packages/server/modules/cli/commands/download/commit.ts index 54c43fed24..137ed821c5 100644 --- a/packages/server/modules/cli/commands/download/commit.ts +++ b/packages/server/modules/cli/commands/download/commit.ts @@ -50,8 +50,10 @@ import { import { validateInputAttachmentsFactory } from '@/modules/comments/services/commentTextService' import { getBlobsFactory } from '@/modules/blobstorage/repositories' import { createCommitByBranchIdFactory } from '@/modules/core/services/commit/management' -import { addCommitCreatedActivity } from '@/modules/activitystream/services/commitActivity' import { VersionsEmitter } from '@/modules/core/events/versionsEmitter' +import { addCommitCreatedActivityFactory } from '@/modules/activitystream/services/commitActivity' +import { saveActivityFactory } from '@/modules/activitystream/repositories' +import { publish } from '@/modules/shared/utils/subscriptions' const command: CommandModule< unknown, @@ -140,7 +142,10 @@ const command: CommandModule< markCommitStreamUpdated, markCommitBranchUpdated: markCommitBranchUpdatedFactory({ db }), versionsEventEmitter: VersionsEmitter.emit, - addCommitCreatedActivity + addCommitCreatedActivity: addCommitCreatedActivityFactory({ + saveActivity: saveActivityFactory({ db }), + publish + }) }) const getStreamCollaborators = getStreamCollaboratorsFactory({ db }) diff --git a/packages/server/modules/cli/commands/download/project.ts b/packages/server/modules/cli/commands/download/project.ts index 354ffb422d..e740252010 100644 --- a/packages/server/modules/cli/commands/download/project.ts +++ b/packages/server/modules/cli/commands/download/project.ts @@ -56,7 +56,6 @@ import { getBlobsFactory } from '@/modules/blobstorage/repositories' import { validateInputAttachmentsFactory } from '@/modules/comments/services/commentTextService' import { addBranchCreatedActivity } from '@/modules/activitystream/services/branchActivity' import { VersionsEmitter } from '@/modules/core/events/versionsEmitter' -import { addCommitCreatedActivity } from '@/modules/activitystream/services/commitActivity' import { createStreamReturnRecordFactory } from '@/modules/core/services/streams/management' import { inviteUsersToProjectFactory } from '@/modules/serverinvites/services/projectInviteManagement' import { createAndSendInviteFactory } from '@/modules/serverinvites/services/creation' @@ -71,6 +70,7 @@ import { ProjectsEmitter } from '@/modules/core/events/projectsEmitter' import { addStreamCreatedActivityFactory } from '@/modules/activitystream/services/streamActivity' import { saveActivityFactory } from '@/modules/activitystream/repositories' import { publish } from '@/modules/shared/utils/subscriptions' +import { addCommitCreatedActivityFactory } from '@/modules/activitystream/services/commitActivity' const command: CommandModule< unknown, @@ -151,7 +151,10 @@ const command: CommandModule< markCommitStreamUpdated, markCommitBranchUpdated: markCommitBranchUpdatedFactory({ db }), versionsEventEmitter: VersionsEmitter.emit, - addCommitCreatedActivity + addCommitCreatedActivity: addCommitCreatedActivityFactory({ + saveActivity: saveActivityFactory({ db }), + publish + }) }) const createStreamReturnRecord = createStreamReturnRecordFactory({ diff --git a/packages/server/modules/comments/tests/comments.graph.spec.js b/packages/server/modules/comments/tests/comments.graph.spec.js index 59b97cec5f..ea62ec190a 100644 --- a/packages/server/modules/comments/tests/comments.graph.spec.js +++ b/packages/server/modules/comments/tests/comments.graph.spec.js @@ -55,9 +55,6 @@ const { grantStreamPermissionsFactory } = require('@/modules/core/repositories/streams') const { VersionsEmitter } = require('@/modules/core/events/versionsEmitter') -const { - addCommitCreatedActivity -} = require('@/modules/activitystream/services/commitActivity') const { getObjectFactory } = require('@/modules/core/repositories/objects') const { legacyCreateStreamFactory, @@ -88,6 +85,9 @@ const { } = require('@/modules/activitystream/services/streamActivity') const { saveActivityFactory } = require('@/modules/activitystream/repositories') const { publish } = require('@/modules/shared/utils/subscriptions') +const { + addCommitCreatedActivityFactory +} = require('@/modules/activitystream/services/commitActivity') const streamResourceCheck = streamResourceCheckFactory({ checkStreamResourceAccess: checkStreamResourceAccessFactory({ db }) @@ -115,7 +115,10 @@ const createCommitByBranchId = createCommitByBranchIdFactory({ markCommitStreamUpdated, markCommitBranchUpdated: markCommitBranchUpdatedFactory({ db }), versionsEventEmitter: VersionsEmitter.emit, - addCommitCreatedActivity + addCommitCreatedActivity: addCommitCreatedActivityFactory({ + saveActivity: saveActivityFactory({ db }), + publish + }) }) const createCommitByBranchName = createCommitByBranchNameFactory({ diff --git a/packages/server/modules/comments/tests/comments.spec.js b/packages/server/modules/comments/tests/comments.spec.js index d76239744b..1173eca3a4 100644 --- a/packages/server/modules/comments/tests/comments.spec.js +++ b/packages/server/modules/comments/tests/comments.spec.js @@ -75,9 +75,6 @@ const { createBranchFactory } = require('@/modules/core/repositories/branches') const { VersionsEmitter } = require('@/modules/core/events/versionsEmitter') -const { - addCommitCreatedActivity -} = require('@/modules/activitystream/services/commitActivity') const { getObjectFactory } = require('@/modules/core/repositories/objects') const { legacyCreateStreamFactory, @@ -107,6 +104,9 @@ const { } = require('@/modules/activitystream/services/streamActivity') const { saveActivityFactory } = require('@/modules/activitystream/repositories') const { publish } = require('@/modules/shared/utils/subscriptions') +const { + addCommitCreatedActivityFactory +} = require('@/modules/activitystream/services/commitActivity') const getStream = getStreamFactory({ db }) const streamResourceCheck = streamResourceCheckFactory({ @@ -164,7 +164,10 @@ const createCommitByBranchId = createCommitByBranchIdFactory({ markCommitStreamUpdated, markCommitBranchUpdated: markCommitBranchUpdatedFactory({ db }), versionsEventEmitter: VersionsEmitter.emit, - addCommitCreatedActivity + addCommitCreatedActivity: addCommitCreatedActivityFactory({ + saveActivity: saveActivityFactory({ db }), + publish + }) }) const createCommitByBranchName = createCommitByBranchNameFactory({ diff --git a/packages/server/modules/core/graph/resolvers/commits.js b/packages/server/modules/core/graph/resolvers/commits.js index 24b706f4a4..ba522bd5d3 100644 --- a/packages/server/modules/core/graph/resolvers/commits.js +++ b/packages/server/modules/core/graph/resolvers/commits.js @@ -2,7 +2,8 @@ const { CommitNotFoundError } = require('@/modules/core/errors/commit') const { withFilter } = require('graphql-subscriptions') const { pubsub, - CommitSubscriptions: CommitPubsubEvents + CommitSubscriptions: CommitPubsubEvents, + publish } = require('@/modules/shared/utils/subscriptions') const { authorizeResolver } = require('@/modules/shared') @@ -66,15 +67,16 @@ const { } = require('@/modules/core/repositories/branches') const { addCommitDeletedActivity, - addCommitCreatedActivity, addCommitUpdatedActivity, - addCommitMovedActivity + addCommitMovedActivity, + addCommitCreatedActivityFactory } = require('@/modules/activitystream/services/commitActivity') const { VersionsEmitter } = require('@/modules/core/events/versionsEmitter') const { getObjectFactory } = require('@/modules/core/repositories/objects') const { validateStreamAccessFactory } = require('@/modules/core/services/streams/access') +const { saveActivityFactory } = require('@/modules/activitystream/repositories') // subscription events const COMMIT_CREATED = CommitPubsubEvents.CommitCreated @@ -102,7 +104,10 @@ const createCommitByBranchId = createCommitByBranchIdFactory({ markCommitStreamUpdated, markCommitBranchUpdated: markCommitBranchUpdatedFactory({ db }), versionsEventEmitter: VersionsEmitter.emit, - addCommitCreatedActivity + addCommitCreatedActivity: addCommitCreatedActivityFactory({ + saveActivity: saveActivityFactory({ db }), + publish + }) }) const createCommitByBranchName = createCommitByBranchNameFactory({ diff --git a/packages/server/modules/core/graph/resolvers/versions.ts b/packages/server/modules/core/graph/resolvers/versions.ts index 114cc13863..94bcf4dd9d 100644 --- a/packages/server/modules/core/graph/resolvers/versions.ts +++ b/packages/server/modules/core/graph/resolvers/versions.ts @@ -3,7 +3,8 @@ import { Resolvers } from '@/modules/core/graph/generated/graphql' import { authorizeResolver } from '@/modules/shared' import { filteredSubscribe, - ProjectSubscriptions + ProjectSubscriptions, + publish } from '@/modules/shared/utils/subscriptions' import { getServerOrigin } from '@/modules/shared/helpers/envHelper' import { @@ -47,11 +48,12 @@ import { } from '@/modules/core/repositories/streams' import { VersionsEmitter } from '@/modules/core/events/versionsEmitter' import { - addCommitCreatedActivity, + addCommitCreatedActivityFactory, addCommitMovedActivity, addCommitUpdatedActivity } from '@/modules/activitystream/services/commitActivity' import { getObjectFactory } from '@/modules/core/repositories/objects' +import { saveActivityFactory } from '@/modules/activitystream/repositories' const getCommitStream = getCommitStreamFactory({ db }) const getStream = getStreamFactory({ db }) @@ -66,7 +68,10 @@ const createCommitByBranchId = createCommitByBranchIdFactory({ markCommitStreamUpdated, markCommitBranchUpdated: markCommitBranchUpdatedFactory({ db }), versionsEventEmitter: VersionsEmitter.emit, - addCommitCreatedActivity + addCommitCreatedActivity: addCommitCreatedActivityFactory({ + saveActivity: saveActivityFactory({ db }), + publish + }) }) const updateCommitAndNotify = updateCommitAndNotifyFactory({ diff --git a/packages/server/modules/core/services/commit/management.ts b/packages/server/modules/core/services/commit/management.ts index a48acead8b..2d4e35ba98 100644 --- a/packages/server/modules/core/services/commit/management.ts +++ b/packages/server/modules/core/services/commit/management.ts @@ -1,6 +1,6 @@ import { db } from '@/db/knex' +import { AddCommitCreatedActivity } from '@/modules/activitystream/domain/operations' import { - addCommitCreatedActivity, addCommitDeletedActivity, addCommitReceivedActivity, addCommitUpdatedActivity @@ -89,7 +89,7 @@ export const createCommitByBranchIdFactory = markCommitStreamUpdated: typeof markCommitStreamUpdated markCommitBranchUpdated: MarkCommitBranchUpdated versionsEventEmitter: VersionsEventEmitter - addCommitCreatedActivity: typeof addCommitCreatedActivity + addCommitCreatedActivity: AddCommitCreatedActivity }): CreateCommitByBranchId => async ( params: { diff --git a/packages/server/modules/core/tests/branches.spec.js b/packages/server/modules/core/tests/branches.spec.js index 867b4f98d8..43d38537c2 100644 --- a/packages/server/modules/core/tests/branches.spec.js +++ b/packages/server/modules/core/tests/branches.spec.js @@ -45,9 +45,6 @@ const { insertBranchCommitsFactory } = require('@/modules/core/repositories/commits') const { VersionsEmitter } = require('@/modules/core/events/versionsEmitter') -const { - addCommitCreatedActivity -} = require('@/modules/activitystream/services/commitActivity') const { getObjectFactory } = require('@/modules/core/repositories/objects') const { legacyCreateStreamFactory, @@ -77,6 +74,9 @@ const { } = require('@/modules/activitystream/services/streamActivity') const { saveActivityFactory } = require('@/modules/activitystream/repositories') const { publish } = require('@/modules/shared/utils/subscriptions') +const { + addCommitCreatedActivityFactory +} = require('@/modules/activitystream/services/commitActivity') const db = knex const Commits = () => knex('commits') @@ -108,7 +108,10 @@ const createCommitByBranchId = createCommitByBranchIdFactory({ markCommitStreamUpdated, markCommitBranchUpdated: markCommitBranchUpdatedFactory({ db }), versionsEventEmitter: VersionsEmitter.emit, - addCommitCreatedActivity + addCommitCreatedActivity: addCommitCreatedActivityFactory({ + saveActivity: saveActivityFactory({ db }), + publish + }) }) const createCommitByBranchName = createCommitByBranchNameFactory({ diff --git a/packages/server/modules/core/tests/commits.spec.js b/packages/server/modules/core/tests/commits.spec.js index 998a9c2770..d516d56947 100644 --- a/packages/server/modules/core/tests/commits.spec.js +++ b/packages/server/modules/core/tests/commits.spec.js @@ -51,7 +51,6 @@ const { } = require('@/modules/core/repositories/streams') const { addCommitDeletedActivity, - addCommitCreatedActivity, addCommitUpdatedActivity } = require('@/modules/activitystream/services/commitActivity') const { VersionsEmitter } = require('@/modules/core/events/versionsEmitter') @@ -112,7 +111,10 @@ const createCommitByBranchId = createCommitByBranchIdFactory({ markCommitStreamUpdated, markCommitBranchUpdated: markCommitBranchUpdatedFactory({ db }), versionsEventEmitter: VersionsEmitter.emit, - addCommitCreatedActivity + addCommitCreatedActivity: addStreamCreatedActivityFactory({ + saveActivity: saveActivityFactory({ db }), + publish + }) }) const createCommitByBranchName = createCommitByBranchNameFactory({ diff --git a/packages/server/modules/core/tests/streams.spec.ts b/packages/server/modules/core/tests/streams.spec.ts index 7620a093a7..518ffd7226 100644 --- a/packages/server/modules/core/tests/streams.spec.ts +++ b/packages/server/modules/core/tests/streams.spec.ts @@ -65,7 +65,7 @@ import { insertStreamCommitsFactory } from '@/modules/core/repositories/commits' import { VersionsEmitter } from '@/modules/core/events/versionsEmitter' -import { addCommitCreatedActivity } from '@/modules/activitystream/services/commitActivity' +import { addCommitCreatedActivityFactory } from '@/modules/activitystream/services/commitActivity' import { getObjectFactory } from '@/modules/core/repositories/objects' import { createStreamReturnRecordFactory, @@ -119,7 +119,10 @@ const createCommitByBranchId = createCommitByBranchIdFactory({ markCommitStreamUpdated, markCommitBranchUpdated: markCommitBranchUpdatedFactory({ db }), versionsEventEmitter: VersionsEmitter.emit, - addCommitCreatedActivity + addCommitCreatedActivity: addCommitCreatedActivityFactory({ + saveActivity: saveActivityFactory({ db }), + publish + }) }) const createCommitByBranchName = createCommitByBranchNameFactory({ diff --git a/packages/server/modules/core/tests/users.spec.js b/packages/server/modules/core/tests/users.spec.js index 29e30e411f..31e5847135 100644 --- a/packages/server/modules/core/tests/users.spec.js +++ b/packages/server/modules/core/tests/users.spec.js @@ -54,9 +54,6 @@ const { grantStreamPermissionsFactory } = require('@/modules/core/repositories/streams') const { VersionsEmitter } = require('@/modules/core/events/versionsEmitter') -const { - addCommitCreatedActivity -} = require('@/modules/activitystream/services/commitActivity') const { getObjectFactory } = require('@/modules/core/repositories/objects') const { legacyCreateStreamFactory, @@ -86,6 +83,9 @@ const { } = require('@/modules/activitystream/services/streamActivity') const { saveActivityFactory } = require('@/modules/activitystream/repositories') const { publish } = require('@/modules/shared/utils/subscriptions') +const { + addCommitCreatedActivityFactory +} = require('@/modules/activitystream/services/commitActivity') const getStream = getStreamFactory({ db }) const createBranch = createBranchFactory({ db }) @@ -101,7 +101,10 @@ const createCommitByBranchId = createCommitByBranchIdFactory({ markCommitStreamUpdated, markCommitBranchUpdated: markCommitBranchUpdatedFactory({ db }), versionsEventEmitter: VersionsEmitter.emit, - addCommitCreatedActivity + addCommitCreatedActivity: addCommitCreatedActivityFactory({ + saveActivity: saveActivityFactory({ db }), + publish + }) }) const createCommitByBranchName = createCommitByBranchNameFactory({ diff --git a/packages/server/modules/cross-server-sync/index.ts b/packages/server/modules/cross-server-sync/index.ts index 301121c3f2..5a59712485 100644 --- a/packages/server/modules/cross-server-sync/index.ts +++ b/packages/server/modules/cross-server-sync/index.ts @@ -6,7 +6,7 @@ import { addCommentCreatedActivity, addReplyAddedActivity } from '@/modules/activitystream/services/commentActivity' -import { addCommitCreatedActivity } from '@/modules/activitystream/services/commitActivity' +import { addCommitCreatedActivityFactory } from '@/modules/activitystream/services/commitActivity' import { addStreamCreatedActivityFactory } from '@/modules/activitystream/services/streamActivity' import { getBlobsFactory } from '@/modules/blobstorage/repositories' import { CommentsEmitter } from '@/modules/comments/events/emitter' @@ -128,7 +128,10 @@ const crossServerSyncModule: SpeckleModule = { markCommitStreamUpdated, markCommitBranchUpdated: markCommitBranchUpdatedFactory({ db }), versionsEventEmitter: VersionsEmitter.emit, - addCommitCreatedActivity + addCommitCreatedActivity: addCommitCreatedActivityFactory({ + saveActivity: saveActivityFactory({ db }), + publish + }) }) const createStreamReturnRecord = createStreamReturnRecordFactory({ diff --git a/packages/server/modules/shared/utils/subscriptions.ts b/packages/server/modules/shared/utils/subscriptions.ts index e2dc4152ab..d97e991b96 100644 --- a/packages/server/modules/shared/utils/subscriptions.ts +++ b/packages/server/modules/shared/utils/subscriptions.ts @@ -304,6 +304,7 @@ type SubscriptionTypeMap = { } & { [k in SubscriptionEvent]: { payload: unknown; variables: unknown } } type SubscriptionEvent = + | CommitSubscriptions | CommentSubscriptions | FileImportSubscriptions | ProjectSubscriptions diff --git a/packages/server/modules/stats/tests/stats.spec.ts b/packages/server/modules/stats/tests/stats.spec.ts index 56c56bfd3a..eba8b180c5 100644 --- a/packages/server/modules/stats/tests/stats.spec.ts +++ b/packages/server/modules/stats/tests/stats.spec.ts @@ -41,7 +41,6 @@ import { markCommitStreamUpdated } from '@/modules/core/repositories/streams' import { VersionsEmitter } from '@/modules/core/events/versionsEmitter' -import { addCommitCreatedActivity } from '@/modules/activitystream/services/commitActivity' import { getObjectFactory } from '@/modules/core/repositories/objects' import { createStreamReturnRecordFactory, @@ -61,6 +60,7 @@ import { ProjectsEmitter } from '@/modules/core/events/projectsEmitter' import { addStreamCreatedActivityFactory } from '@/modules/activitystream/services/streamActivity' import { saveActivityFactory } from '@/modules/activitystream/repositories' import { publish } from '@/modules/shared/utils/subscriptions' +import { addCommitCreatedActivityFactory } from '@/modules/activitystream/services/commitActivity' const getObject = getObjectFactory({ db }) const createCommitByBranchId = createCommitByBranchIdFactory({ @@ -72,7 +72,10 @@ const createCommitByBranchId = createCommitByBranchIdFactory({ markCommitStreamUpdated, markCommitBranchUpdated: markCommitBranchUpdatedFactory({ db }), versionsEventEmitter: VersionsEmitter.emit, - addCommitCreatedActivity + addCommitCreatedActivity: addCommitCreatedActivityFactory({ + saveActivity: saveActivityFactory({ db }), + publish + }) }) const createCommitByBranchName = createCommitByBranchNameFactory({ diff --git a/packages/server/test/speckle-helpers/commitHelper.ts b/packages/server/test/speckle-helpers/commitHelper.ts index 98cab64c3d..0ddf509248 100644 --- a/packages/server/test/speckle-helpers/commitHelper.ts +++ b/packages/server/test/speckle-helpers/commitHelper.ts @@ -1,5 +1,6 @@ import { db } from '@/db/knex' -import { addCommitCreatedActivity } from '@/modules/activitystream/services/commitActivity' +import { saveActivityFactory } from '@/modules/activitystream/repositories' +import { addCommitCreatedActivityFactory } from '@/modules/activitystream/services/commitActivity' import { VersionsEmitter } from '@/modules/core/events/versionsEmitter' import { getBranchByIdFactory, @@ -18,6 +19,7 @@ import { createCommitByBranchNameFactory } from '@/modules/core/services/commit/management' import { createObject } from '@/modules/core/services/objects' +import { publish } from '@/modules/shared/utils/subscriptions' import { BasicTestUser } from '@/test/authHelper' import { BasicTestStream } from '@/test/speckle-helpers/streamHelper' @@ -31,7 +33,10 @@ const createCommitByBranchId = createCommitByBranchIdFactory({ markCommitStreamUpdated, markCommitBranchUpdated: markCommitBranchUpdatedFactory({ db }), versionsEventEmitter: VersionsEmitter.emit, - addCommitCreatedActivity + addCommitCreatedActivity: addCommitCreatedActivityFactory({ + saveActivity: saveActivityFactory({ db }), + publish + }) }) const createCommitByBranchName = createCommitByBranchNameFactory({