Added timestamp internally in urls to avoid caching

This commit is contained in:
Davidson Gomes 2023-07-01 10:17:29 -03:00
parent b1c527cb71
commit 2519efb3ea
2 changed files with 21 additions and 4 deletions

View File

@ -1,3 +1,9 @@
# 1.1.3 (homolog)
### Fixed
* Added timestamp internally in urls to avoid caching
# 1.1.2 (2023-06-28 13:43) # 1.1.2 (2023-06-28 13:43)
### Fixed ### Fixed

View File

@ -30,6 +30,7 @@ import makeWASocket, {
WAMessageUpdate, WAMessageUpdate,
WASocket, WASocket,
getAggregateVotesInPollMessage, getAggregateVotesInPollMessage,
makeInMemoryStore,
} from '@whiskeysockets/baileys'; } from '@whiskeysockets/baileys';
import { import {
Auth, Auth,
@ -486,10 +487,11 @@ export class WAStartupService {
const session = this.configService.get<ConfigSessionPhone>('CONFIG_SESSION_PHONE'); const session = this.configService.get<ConfigSessionPhone>('CONFIG_SESSION_PHONE');
const browser: WABrowserDescription = [session.CLIENT, session.NAME, release()]; const browser: WABrowserDescription = [session.CLIENT, session.NAME, release()];
const store = makeInMemoryStore({ logger: P({ level: 'error' }) });
const socketConfig: UserFacingSocketConfig = { const socketConfig: UserFacingSocketConfig = {
auth: { auth: {
creds: this.instance.authState.state.creds, creds: this.instance.authState.state.creds,
/** caching makes the store faster to send/recv messages */
keys: makeCacheableSignalKeyStore( keys: makeCacheableSignalKeyStore(
this.instance.authState.state.keys, this.instance.authState.state.keys,
P({ level: 'error' }), P({ level: 'error' }),
@ -1205,7 +1207,10 @@ export class WAStartupService {
outputAudio = `${join(process.cwd(), 'temp', 'audio.mp4')}`; outputAudio = `${join(process.cwd(), 'temp', 'audio.mp4')}`;
tempAudioPath = `${join(process.cwd(), 'temp', 'audioTemp.mp3')}`; tempAudioPath = `${join(process.cwd(), 'temp', 'audioTemp.mp3')}`;
const response = await axios.get(audio, { responseType: 'arraybuffer' }); const timestamp = new Date().getTime();
const url = `${audio}?timestamp=${timestamp}`;
const response = await axios.get(url, { responseType: 'arraybuffer' });
fs.writeFileSync(tempAudioPath, response.data); fs.writeFileSync(tempAudioPath, response.data);
} else { } else {
outputAudio = `${join(process.cwd(), 'temp', 'audio.mp4')}`; outputAudio = `${join(process.cwd(), 'temp', 'audio.mp4')}`;
@ -1642,7 +1647,10 @@ export class WAStartupService {
try { try {
let pic: WAMediaUpload; let pic: WAMediaUpload;
if (isURL(picture)) { if (isURL(picture)) {
pic = (await axios.get(picture, { responseType: 'arraybuffer' })).data; const timestamp = new Date().getTime();
const url = `${picture}?timestamp=${timestamp}`;
pic = (await axios.get(url, { responseType: 'arraybuffer' })).data;
} else if (isBase64(picture)) { } else if (isBase64(picture)) {
pic = Buffer.from(picture, 'base64'); pic = Buffer.from(picture, 'base64');
} else { } else {
@ -1694,7 +1702,10 @@ export class WAStartupService {
try { try {
let pic: WAMediaUpload; let pic: WAMediaUpload;
if (isURL(picture.image)) { if (isURL(picture.image)) {
pic = (await axios.get(picture.image, { responseType: 'arraybuffer' })).data; const timestamp = new Date().getTime();
const url = `${picture.image}?timestamp=${timestamp}`;
pic = (await axios.get(url, { responseType: 'arraybuffer' })).data;
} else if (isBase64(picture.image)) { } else if (isBase64(picture.image)) {
pic = Buffer.from(picture.image, 'base64'); pic = Buffer.from(picture.image, 'base64');
} else { } else {