diff --git a/prisma/postgresql-migrations/20250225180031_add_nats_integration/migration.sql b/prisma/postgresql-migrations/20250225180031_add_nats_integration/migration.sql new file mode 100644 index 00000000..1e6c0e60 --- /dev/null +++ b/prisma/postgresql-migrations/20250225180031_add_nats_integration/migration.sql @@ -0,0 +1,17 @@ +-- CreateTable +CREATE TABLE "Nats" ( + "id" TEXT NOT NULL, + "enabled" BOOLEAN NOT NULL DEFAULT false, + "events" JSONB NOT NULL, + "createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP NOT NULL, + "instanceId" TEXT NOT NULL, + + CONSTRAINT "Nats_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "Nats_instanceId_key" ON "Nats"("instanceId"); + +-- AddForeignKey +ALTER TABLE "Nats" ADD CONSTRAINT "Nats_instanceId_fkey" FOREIGN KEY ("instanceId") REFERENCES "Instance"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts index 93d70efb..7e9b6f10 100644 --- a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts @@ -1148,23 +1148,23 @@ export class BaileysStartupService extends ChannelStartupService { } } - if (received.messageStubParameters && received.messageStubParameters[0] === 'Message absent from node') { - this.logger.info(`Recovering message lost messageId: ${received.key.id}`); + // if (received.messageStubParameters && received.messageStubParameters[0] === 'Message absent from node') { + // this.logger.info(`Recovering message lost messageId: ${received.key.id}`); - await this.baileysCache.set(received.key.id, { - message: received, - retry: 0, - }); + // await this.baileysCache.set(received.key.id, { + // message: received, + // retry: 0, + // }); - continue; - } + // continue; + // } - const retryCache = (await this.baileysCache.get(received.key.id)) || null; + // const retryCache = (await this.baileysCache.get(received.key.id)) || null; - if (retryCache) { - this.logger.info('Recovered message lost'); - await this.baileysCache.delete(received.key.id); - } + // if (retryCache) { + // this.logger.info('Recovered message lost'); + // await this.baileysCache.delete(received.key.id); + // } // Cache to avoid duplicate messages const messageKey = `${this.instance.id}_${received.key.id}`; diff --git a/src/api/routes/instance.router.ts b/src/api/routes/instance.router.ts index dd990c3b..3559893e 100644 --- a/src/api/routes/instance.router.ts +++ b/src/api/routes/instance.router.ts @@ -15,7 +15,6 @@ export class InstanceRouter extends RouterBroker { super(); this.router .post('/create', ...guards, async (req, res) => { - console.log('create instance', req.body); const response = await this.dataValidate({ request: req, schema: instanceSchema,