mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-15 19:52:54 -06:00
Correction in decryption of poll votes
This commit is contained in:
parent
2519efb3ea
commit
d7d0e5ec82
@ -3,6 +3,8 @@
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
* Added timestamp internally in urls to avoid caching
|
* Added timestamp internally in urls to avoid caching
|
||||||
|
* Correction in decryption of poll votes
|
||||||
|
* Change in the way the api sent and saved the sent messages, now it goes in the messages.upsert event
|
||||||
|
|
||||||
# 1.1.2 (2023-06-28 13:43)
|
# 1.1.2 (2023-06-28 13:43)
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ export class MessageUpdateRaw {
|
|||||||
datetime?: number;
|
datetime?: number;
|
||||||
status?: wa.StatusMessage;
|
status?: wa.StatusMessage;
|
||||||
owner: string;
|
owner: string;
|
||||||
|
pollUpdates?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
const messageUpdateSchema = new Schema<MessageUpdateRaw>({
|
const messageUpdateSchema = new Schema<MessageUpdateRaw>({
|
||||||
|
@ -135,6 +135,7 @@ export class WAStartupService {
|
|||||||
private readonly msgRetryCounterCache: CacheStore = new NodeCache();
|
private readonly msgRetryCounterCache: CacheStore = new NodeCache();
|
||||||
private readonly userDevicesCache: CacheStore = new NodeCache();
|
private readonly userDevicesCache: CacheStore = new NodeCache();
|
||||||
private endSession = false;
|
private endSession = false;
|
||||||
|
private store = makeInMemoryStore({ logger: P({ level: 'error' }) });
|
||||||
|
|
||||||
public set instanceName(name: string) {
|
public set instanceName(name: string) {
|
||||||
if (!name) {
|
if (!name) {
|
||||||
@ -440,6 +441,15 @@ export class WAStartupService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async getMessageStore(key: proto.IMessageKey) {
|
||||||
|
if (this.store) {
|
||||||
|
const msg = await this.store.loadMessage(key.remoteJid!, key.id!);
|
||||||
|
return msg?.message || undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return proto.Message.fromObject({});
|
||||||
|
}
|
||||||
|
|
||||||
private cleanStore() {
|
private cleanStore() {
|
||||||
const cleanStore = this.configService.get<CleanStoreConf>('CLEAN_STORE');
|
const cleanStore = this.configService.get<CleanStoreConf>('CLEAN_STORE');
|
||||||
const database = this.configService.get<Database>('DATABASE');
|
const database = this.configService.get<Database>('DATABASE');
|
||||||
@ -455,6 +465,7 @@ export class WAStartupService {
|
|||||||
this.instance.wuid,
|
this.instance.wuid,
|
||||||
)}/*.json`,
|
)}/*.json`,
|
||||||
);
|
);
|
||||||
|
this.store?.writeToFile(`${this.storePath}/baileys_store_multi.json`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
@ -487,7 +498,7 @@ 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' }) });
|
this.store?.readFromFile(`${this.storePath}/baileys_store_multi.json`);
|
||||||
|
|
||||||
const socketConfig: UserFacingSocketConfig = {
|
const socketConfig: UserFacingSocketConfig = {
|
||||||
auth: {
|
auth: {
|
||||||
@ -505,7 +516,8 @@ export class WAStartupService {
|
|||||||
qrTimeout: 40_000,
|
qrTimeout: 40_000,
|
||||||
emitOwnEvents: false,
|
emitOwnEvents: false,
|
||||||
msgRetryCounterCache: this.msgRetryCounterCache,
|
msgRetryCounterCache: this.msgRetryCounterCache,
|
||||||
getMessage: this.getMessage as any,
|
getMessage: async (key) =>
|
||||||
|
(await this.getMessageStore(key)) as Promise<proto.IMessage>,
|
||||||
generateHighQualityLinkPreview: true,
|
generateHighQualityLinkPreview: true,
|
||||||
syncFullHistory: true,
|
syncFullHistory: true,
|
||||||
userDevicesCache: this.userDevicesCache,
|
userDevicesCache: this.userDevicesCache,
|
||||||
@ -538,6 +550,8 @@ export class WAStartupService {
|
|||||||
|
|
||||||
this.client = makeWASocket(socketConfig);
|
this.client = makeWASocket(socketConfig);
|
||||||
|
|
||||||
|
this.store?.bind(this.client.ev);
|
||||||
|
|
||||||
this.eventHandler();
|
this.eventHandler();
|
||||||
|
|
||||||
return this.client;
|
return this.client;
|
||||||
@ -693,10 +707,6 @@ export class WAStartupService {
|
|||||||
|
|
||||||
this.sendDataWebhook(Events.MESSAGES_SET, [...messagesRaw]);
|
this.sendDataWebhook(Events.MESSAGES_SET, [...messagesRaw]);
|
||||||
|
|
||||||
// await this.repository.message.insert(
|
|
||||||
// [...messagesRaw],
|
|
||||||
// database.SAVE_DATA.OLD_MESSAGE,
|
|
||||||
// );
|
|
||||||
messages = undefined;
|
messages = undefined;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -747,15 +757,14 @@ export class WAStartupService {
|
|||||||
};
|
};
|
||||||
for await (const { key, update } of args) {
|
for await (const { key, update } of args) {
|
||||||
if (key.remoteJid !== 'status@broadcast' && !key?.remoteJid?.match(/(:\d+)/)) {
|
if (key.remoteJid !== 'status@broadcast' && !key?.remoteJid?.match(/(:\d+)/)) {
|
||||||
|
let pollUpdates: any;
|
||||||
if (update.pollUpdates) {
|
if (update.pollUpdates) {
|
||||||
const pollCreation = await this.getMessage(key);
|
const pollCreation = await this.getMessageStore(key);
|
||||||
console.log('pollCreation: ', pollCreation);
|
|
||||||
if (pollCreation) {
|
if (pollCreation) {
|
||||||
const pollMessage = getAggregateVotesInPollMessage({
|
pollUpdates = getAggregateVotesInPollMessage({
|
||||||
message: pollCreation as proto.IMessage,
|
message: pollCreation as proto.IMessage,
|
||||||
pollUpdates: update.pollUpdates,
|
pollUpdates: update.pollUpdates,
|
||||||
});
|
});
|
||||||
console.log('pollMessage: ', pollMessage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,6 +773,7 @@ export class WAStartupService {
|
|||||||
status: status[update.status],
|
status: status[update.status],
|
||||||
datetime: Date.now(),
|
datetime: Date.now(),
|
||||||
owner: this.instance.wuid,
|
owner: this.instance.wuid,
|
||||||
|
pollUpdates,
|
||||||
};
|
};
|
||||||
|
|
||||||
await this.sendDataWebhook(Events.MESSAGES_UPDATE, message);
|
await this.sendDataWebhook(Events.MESSAGES_UPDATE, message);
|
||||||
@ -1043,17 +1053,10 @@ export class WAStartupService {
|
|||||||
|
|
||||||
messageSent['messageType'] = getContentType(messageSent.message);
|
messageSent['messageType'] = getContentType(messageSent.message);
|
||||||
|
|
||||||
this.logger.log(messageSent);
|
this.client.ev.emit('messages.upsert', {
|
||||||
|
messages: [messageSent],
|
||||||
this.sendDataWebhook(Events.SEND_MESSAGE, messageSent).catch((error) =>
|
type: 'notify',
|
||||||
this.logger.error(error),
|
});
|
||||||
);
|
|
||||||
this.repository.message
|
|
||||||
.insert(
|
|
||||||
[{ ...messageSent, owner: this.instance.wuid }],
|
|
||||||
this.configService.get<Database>('DATABASE').SAVE_DATA.NEW_MESSAGE,
|
|
||||||
)
|
|
||||||
.catch((error) => this.logger.error(error));
|
|
||||||
|
|
||||||
return messageSent;
|
return messageSent;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -1465,8 +1468,6 @@ export class WAStartupService {
|
|||||||
? m
|
? m
|
||||||
: ((await this.getMessage(m.key, true)) as proto.IWebMessageInfo);
|
: ((await this.getMessage(m.key, true)) as proto.IWebMessageInfo);
|
||||||
|
|
||||||
console.log(msg);
|
|
||||||
|
|
||||||
for (const subtype of MessageSubtype) {
|
for (const subtype of MessageSubtype) {
|
||||||
if (msg.message[subtype]) {
|
if (msg.message[subtype]) {
|
||||||
msg.message = msg.message[subtype].message;
|
msg.message = msg.message[subtype].message;
|
||||||
|
Loading…
Reference in New Issue
Block a user