Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

fix: resolve the webhook post by releaseId fallback

Gilad Resisib193042126cf
diff --git a/apps/orchestrator/src/activities/post.activity.ts b/apps/orchestrator/src/activities/post.activity.ts
index 271213f2a..5c18c3475 100644
--- a/apps/orchestrator/src/activities/post.activity.ts
+++ b/apps/orchestrator/src/activities/post.activity.ts
@@ -498,7 +498,10 @@ export class PostActivity {
return;
}
- const post = await this._postService.getPostByForWebhookId(postId);
+ const post = await this._postService.getPostByForWebhookId(
+ postId,
+ integrationId
+ );
await Promise.all(
webhooks.map(async (webhook) => {
try {
diff --git a/libraries/nestjs-libraries/src/database/prisma/posts/posts.repository.ts b/libraries/nestjs-libraries/src/database/prisma/posts/posts.repository.ts
index 4d6e240f6..5741b6a96 100644
--- a/libraries/nestjs-libraries/src/database/prisma/posts/posts.repository.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/posts/posts.repository.ts
@@ -884,29 +884,51 @@ export class PostsRepository {
});
}
- async getPostByForWebhookId(postId: string) {
- return this._post.model.post.findMany({
+ async getPostByForWebhookId(postId: string, integrationId: string) {
+ const select = {
+ id: true,
+ content: true,
+ publishDate: true,
+ releaseURL: true,
+ state: true,
+ integration: {
+ select: {
+ id: true,
+ name: true,
+ providerIdentifier: true,
+ picture: true,
+ type: true,
+ },
+ },
+ };
+
+ const posts = await this._post.model.post.findMany({
where: {
id: postId,
deletedAt: null,
parentPostId: null,
},
- select: {
- id: true,
- content: true,
- publishDate: true,
- releaseURL: true,
- state: true,
- integration: {
- select: {
- id: true,
- name: true,
- providerIdentifier: true,
- picture: true,
- type: true,
- },
- },
+ select,
+ });
+
+ if (posts.length) {
+ return posts;
+ }
+
+ // The running workflows pass the platform's post id, which updatePost
+ // already stored on the row as releaseId before the webhook is sent.
+ return this._post.model.post.findMany({
+ where: {
+ releaseId: postId,
+ integrationId,
+ deletedAt: null,
+ parentPostId: null,
+ },
+ orderBy: {
+ updatedAt: 'desc' as const,
},
+ take: 1,
+ select,
});
}
diff --git a/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts b/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts
index cff3bb38b..fd60fb59b 100644
--- a/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts
@@ -688,8 +688,8 @@ export class PostsService {
return this._postRepository.countPostsFromDay(orgId, date);
}
- getPostByForWebhookId(id: string) {
- return this._postRepository.getPostByForWebhookId(id);
+ getPostByForWebhookId(id: string, integrationId: string) {
+ return this._postRepository.getPostByForWebhookId(id, integrationId);
}
async startWorkflow(