Skip to content

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

feat: fix auto post

Nevo Davidd883bfa159dc
diff --git a/apps/orchestrator/src/app.module.ts b/apps/orchestrator/src/app.module.ts
index 1e5ca89ad..62fc5ab5b 100644
--- a/apps/orchestrator/src/app.module.ts
+++ b/apps/orchestrator/src/app.module.ts
@@ -2,7 +2,7 @@ import { Module } from '@nestjs/common';
import { PostActivity } from '@gitroom/orchestrator/activities/post.activity';
import { getTemporalModule } from '@gitroom/nestjs-libraries/temporal/temporal.module';
import { DatabaseModule } from '@gitroom/nestjs-libraries/database/prisma/database.module';
-import { AutopostService } from '@gitroom/nestjs-libraries/database/prisma/autopost/autopost.service';
+import { AutopostActivity } from '@gitroom/orchestrator/activities/autopost.activity';
import { EmailActivity } from '@gitroom/orchestrator/activities/email.activity';
import { IntegrationsActivity } from '@gitroom/orchestrator/activities/integrations.activity';
import { VideoActivity } from '@gitroom/orchestrator/activities/video.activity';
@@ -13,7 +13,7 @@ import { HealthController } from '@gitroom/orchestrator/health.controller';
const activities = [
PostActivity,
- AutopostService,
+ AutopostActivity,
EmailActivity,
IntegrationsActivity,
VideoActivity,
diff --git a/libraries/nestjs-libraries/src/database/prisma/autopost/autopost.service.ts b/libraries/nestjs-libraries/src/database/prisma/autopost/autopost.service.ts
index 9b7f9e9ee..fb3aff942 100644
--- a/libraries/nestjs-libraries/src/database/prisma/autopost/autopost.service.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/autopost/autopost.service.ts
@@ -103,12 +103,14 @@ export class AutopostService {
async processCron(active: boolean, orgId: string, id: string) {
if (active) {
try {
- return this._temporalService.client
+ return await this._temporalService.client
.getRawClient()
?.workflow.start('autoPostWorkflow', {
workflowId: `autopost-${id}`,
taskQueue: 'main',
args: [{ id, immediately: true }],
+ // Keep a running workflow, it reads the autopost settings on every run
+ workflowIdConflictPolicy: 'USE_EXISTING',
typedSearchAttributes: new TypedSearchAttributes([
{
key: organizationId,
@@ -116,7 +118,10 @@ export class AutopostService {
},
]),
});
- } catch (err) {}
+ } catch (err) {
+ // Don't fall through and terminate an active autopost
+ return false;
+ }
}
try {