mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 09:51:24 -06:00
feat: Add NATS integration and update Baileys service
- Create Nats table in PostgreSQL migration - Disable message recovery logic in Baileys service - Remove console log in instance creation route
This commit is contained in:
parent
b58d9e957f
commit
8a54efe11c
@ -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;
|
@ -1148,23 +1148,23 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (received.messageStubParameters && received.messageStubParameters[0] === 'Message absent from node') {
|
// if (received.messageStubParameters && received.messageStubParameters[0] === 'Message absent from node') {
|
||||||
this.logger.info(`Recovering message lost messageId: ${received.key.id}`);
|
// this.logger.info(`Recovering message lost messageId: ${received.key.id}`);
|
||||||
|
|
||||||
await this.baileysCache.set(received.key.id, {
|
// await this.baileysCache.set(received.key.id, {
|
||||||
message: received,
|
// message: received,
|
||||||
retry: 0,
|
// 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) {
|
// if (retryCache) {
|
||||||
this.logger.info('Recovered message lost');
|
// this.logger.info('Recovered message lost');
|
||||||
await this.baileysCache.delete(received.key.id);
|
// await this.baileysCache.delete(received.key.id);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Cache to avoid duplicate messages
|
// Cache to avoid duplicate messages
|
||||||
const messageKey = `${this.instance.id}_${received.key.id}`;
|
const messageKey = `${this.instance.id}_${received.key.id}`;
|
||||||
|
@ -15,7 +15,6 @@ export class InstanceRouter extends RouterBroker {
|
|||||||
super();
|
super();
|
||||||
this.router
|
this.router
|
||||||
.post('/create', ...guards, async (req, res) => {
|
.post('/create', ...guards, async (req, res) => {
|
||||||
console.log('create instance', req.body);
|
|
||||||
const response = await this.dataValidate<InstanceDto>({
|
const response = await this.dataValidate<InstanceDto>({
|
||||||
request: req,
|
request: req,
|
||||||
schema: instanceSchema,
|
schema: instanceSchema,
|
||||||
|
Loading…
Reference in New Issue
Block a user