mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
MessageInfo
This commit is contained in:
@@ -58,6 +58,7 @@ export const HKDFInfoKeys = {
|
|||||||
}
|
}
|
||||||
export enum Mimetype {
|
export enum Mimetype {
|
||||||
jpeg = 'image/jpeg',
|
jpeg = 'image/jpeg',
|
||||||
|
png = 'image/png',
|
||||||
mp4 = 'video/mp4',
|
mp4 = 'video/mp4',
|
||||||
gif = 'video/gif',
|
gif = 'video/gif',
|
||||||
pdf = 'appliction/pdf',
|
pdf = 'appliction/pdf',
|
||||||
@@ -74,6 +75,10 @@ export interface MessageOptions {
|
|||||||
validateID?: boolean,
|
validateID?: boolean,
|
||||||
filename?: string
|
filename?: string
|
||||||
}
|
}
|
||||||
|
export interface MessageInfo {
|
||||||
|
reads: {jid: string, t: string}[]
|
||||||
|
deliveries: {jid: string, t: string}[]
|
||||||
|
}
|
||||||
export interface MessageStatusUpdate {
|
export interface MessageStatusUpdate {
|
||||||
from: string
|
from: string
|
||||||
to: string
|
to: string
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
WASendMessageResponse,
|
WASendMessageResponse,
|
||||||
WAMessageKey,
|
WAMessageKey,
|
||||||
ChatModification,
|
ChatModification,
|
||||||
|
MessageInfo,
|
||||||
} from './Constants'
|
} from './Constants'
|
||||||
import { generateMessageID, sha256, hmacSign, aesEncrypWithIV, randomBytes } from '../WAConnection/Utils'
|
import { generateMessageID, sha256, hmacSign, aesEncrypWithIV, randomBytes } from '../WAConnection/Utils'
|
||||||
import { WAMessageContent, WAMetric, WAFlag, WANode, WAMessage } from '../WAConnection/Constants'
|
import { WAMessageContent, WAMetric, WAFlag, WANode, WAMessage } from '../WAConnection/Constants'
|
||||||
@@ -21,7 +22,19 @@ export default class WhatsAppWebMessages extends WhatsAppWebBase {
|
|||||||
/** Get the message info, who has read it, who its been delivered to */
|
/** Get the message info, who has read it, who its been delivered to */
|
||||||
async messageInfo (jid: string, messageID: string) {
|
async messageInfo (jid: string, messageID: string) {
|
||||||
const query = ['query', {type: 'message_info', index: messageID, jid: jid, epoch: this.msgCount.toString()}, null]
|
const query = ['query', {type: 'message_info', index: messageID, jid: jid, epoch: this.msgCount.toString()}, null]
|
||||||
return this.queryExpecting200 (query, [22, WAFlag.ignore])
|
const response = (await this.queryExpecting200 (query, [22, WAFlag.ignore]))[2] as WANode[]
|
||||||
|
|
||||||
|
const info: MessageInfo = {reads: [], deliveries: []}
|
||||||
|
|
||||||
|
const reads = response.filter (node => node[0] === 'read')
|
||||||
|
if (reads[0]) {
|
||||||
|
info.reads = reads[0][2].map (item => item[1])
|
||||||
|
}
|
||||||
|
const deliveries = response.filter (node => node[0] === 'delivery')
|
||||||
|
if (reads[0]) {
|
||||||
|
info.reads = reads[0][2].map (item => item[1])
|
||||||
|
}
|
||||||
|
return info
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Send a read receipt to the given ID for a certain message
|
* Send a read receipt to the given ID for a certain message
|
||||||
|
|||||||
Reference in New Issue
Block a user