Skip to content

Commit

Permalink
improve callout creation subscription performance (#4885)
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinyanakiev authored Jan 28, 2025
1 parent d9e951c commit 8ef7dc3
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/domain/collaboration/callout/callout.resolver.mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,29 @@ export class CalloutResolverMutations {
);
await this.authorizationPolicyService.saveAll(updatedAuthorizations);

if (contributionData.post && contribution.post) {
const postCreatedEvent: CalloutPostCreatedPayload = {
eventID: `callout-post-created-${Math.round(Math.random() * 100)}`,
calloutID: callout.id,
contributionID: contribution.id,
sortOrder: contribution.sortOrder,
post: {
// Removing the storageBucket from the post because it cannot be stringified
// due to a circular reference (storageBucket => documents[] => storageBucket)
// The client is not querying it from the subscription anyway.
...contribution.post,
profile: {
...contribution.post.profile,
storageBucket: undefined,
},
},
};
this.postCreatedSubscription.publish(
SubscriptionType.CALLOUT_POST_CREATED,
postCreatedEvent
);
}

//toDo - rework activities also for CalloutSetType.KNOWLEDGE_BASE
// Get the levelZeroSpaceID for the callout
if (callout.calloutsSet.type === CalloutsSetType.COLLABORATION) {
Expand All @@ -275,7 +298,7 @@ export class CalloutResolverMutations {

if (contributionData.link && contribution.link) {
if (callout.visibility === CalloutVisibility.PUBLISHED) {
await this.processActivityLinkCreated(
this.processActivityLinkCreated(
callout,
contribution.link,
levelZeroSpaceID,
Expand All @@ -297,29 +320,6 @@ export class CalloutResolverMutations {
}
}

if (contributionData.post && contribution.post) {
const postCreatedEvent: CalloutPostCreatedPayload = {
eventID: `callout-post-created-${Math.round(Math.random() * 100)}`,
calloutID: callout.id,
contributionID: contribution.id,
sortOrder: contribution.sortOrder,
post: {
// Removing the storageBucket from the post because it cannot be stringified
// due to a circular reference (storageBucket => documents[] => storageBucket)
// The client is not querying it from the subscription anyway.
...contribution.post,
profile: {
...contribution.post.profile,
storageBucket: undefined,
},
},
};
await this.postCreatedSubscription.publish(
SubscriptionType.CALLOUT_POST_CREATED,
postCreatedEvent
);
}

return await this.calloutContributionService.getCalloutContributionOrFail(
contribution.id
);
Expand Down

0 comments on commit 8ef7dc3

Please sign in to comment.