Skip to content

Commit

Permalink
Merge branch 'release/2.3.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidsonGomes committed Apr 19, 2024
2 parents 371ec9b + c85619e commit e071f56
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 111 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 1.7.4 (develop)

### Fixed
* Adjusts in proxy on fetchAgent
* Recovering messages lost with redis cache
* Log when init redis cache service

# 1.7.3 (2024-04-18 12:07)

### Fixed
Expand Down
1 change: 1 addition & 0 deletions src/api/models/message.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class MessageRaw {
source_reply_id?: string;
chatwoot?: ChatwootMessage;
contextInfo?: any;
status?: wa.StatusMessage | any;
}

type MessageRawBoolean<T> = {
Expand Down
16 changes: 15 additions & 1 deletion src/api/services/whatsapp/whatsapp.baileys.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class BaileysStartupService extends WAStartupService {
const cacheConf = this.configService.get<CacheConf>('CACHE');

if ((cacheConf?.REDIS?.ENABLED && cacheConf?.REDIS?.URI !== '') || cacheConf?.LOCAL?.ENABLED) {
setTimeout(async () => {
setInterval(async () => {
this.logger.info('Recovering messages');
this.messagesLostCache.keys().then((keys) => {
keys.forEach(async (key) => {
Expand Down Expand Up @@ -517,13 +517,15 @@ export class BaileysStartupService extends WAStartupService {
const proxyUrl = 'http://' + proxyUrls[rand];
options = {
agent: makeProxyAgent(proxyUrl),
fetchAgent: makeProxyAgent(proxyUrl),
};
} catch (error) {
this.localProxy.enabled = false;
}
} else {
options = {
agent: makeProxyAgent(this.localProxy.proxy),
fetchAgent: makeProxyAgent(this.localProxy.proxy),
};
}
}
Expand Down Expand Up @@ -687,13 +689,15 @@ export class BaileysStartupService extends WAStartupService {
const proxyUrl = 'http://' + proxyUrls[rand];
options = {
agent: makeProxyAgent(proxyUrl),
fetchAgent: makeProxyAgent(proxyUrl),
};
} catch (error) {
this.localProxy.enabled = false;
}
} else {
options = {
agent: makeProxyAgent(this.localProxy.proxy),
fetchAgent: makeProxyAgent(this.localProxy.proxy),
};
}
}
Expand Down Expand Up @@ -997,6 +1001,15 @@ export class BaileysStartupService extends WAStartupService {
continue;
}

const status: Record<number, wa.StatusMessage> = {
0: 'ERROR',
1: 'PENDING',
2: 'SERVER_ACK',
3: 'DELIVERY_ACK',
4: 'READ',
5: 'PLAYED',
};

messagesRaw.push({
key: m.key,
pushName: m.pushName || m.key.remoteJid.split('@')[0],
Expand All @@ -1005,6 +1018,7 @@ export class BaileysStartupService extends WAStartupService {
messageType: getContentType(m.message),
messageTimestamp: m.messageTimestamp as number,
owner: this.instance.name,
status: m.status ? status[m.status] : null,
});
}

Expand Down
5 changes: 5 additions & 0 deletions src/cache/cacheengine.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { ICache } from '../api/abstract/abstract.cache';
import { CacheConf, ConfigService } from '../config/env.config';
import { Logger } from '../config/logger.config';
import { LocalCache } from './localcache';
import { RedisCache } from './rediscache';

const logger = new Logger('Redis');

export class CacheEngine {
private engine: ICache;

Expand All @@ -14,6 +17,8 @@ export class CacheEngine {
} else if (cacheConf?.LOCAL?.ENABLED) {
this.engine = new LocalCache(configService, module);
}

logger.info(`RedisCache initialized for ${module}`);
}

public getEngine() {
Expand Down
110 changes: 0 additions & 110 deletions views/manager-wip.hbs

This file was deleted.

0 comments on commit e071f56

Please sign in to comment.