Skip to content

Commit

Permalink
send subscription updates on callout creation
Browse files Browse the repository at this point in the history
add toDo
  • Loading branch information
valentinyanakiev committed Jan 27, 2025
1 parent 29b0c8c commit fe6dcb3
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions src/domain/collaboration/callout/callout.resolver.mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export class CalloutResolverMutations {
);
await this.authorizationPolicyService.saveAll(updatedAuthorizations);

//toDo - rework activities also for CalloutSetType.KNOWLEDGE_BASE
// Get the levelZeroSpaceID for the callout
if (callout.calloutsSet.type === CalloutsSetType.COLLABORATION) {
const levelZeroSpaceID =
Expand All @@ -261,27 +262,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
);

if (callout.visibility === CalloutVisibility.PUBLISHED) {
this.processActivityPostCreated(
callout,
Expand Down Expand Up @@ -317,6 +297,29 @@ 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 fe6dcb3

Please sign in to comment.