mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Depracations + Semantic Changes
This commit is contained in:
@@ -23,7 +23,7 @@ export default class Decoder {
|
||||
const value = this.buffer.slice(this.index, this.index + length)
|
||||
|
||||
this.index += length
|
||||
return new TextDecoder().decode(value)
|
||||
return value.toString ('utf-8')
|
||||
}
|
||||
readBytes(n: number): Buffer {
|
||||
this.checkEOS(n)
|
||||
|
||||
@@ -20,7 +20,7 @@ export default class Encoder {
|
||||
this.data.push.apply(this.data, bytes)
|
||||
}
|
||||
pushString(str: string) {
|
||||
const bytes = new TextEncoder().encode(str)
|
||||
const bytes = Buffer.from (str, 'utf-8')
|
||||
this.pushBytes(bytes)
|
||||
}
|
||||
writeByteLength(length: number) {
|
||||
|
||||
@@ -43,12 +43,6 @@ export enum ChatModification {
|
||||
mute='mute',
|
||||
unmute='unmute'
|
||||
}
|
||||
export const WAMessageType = function () {
|
||||
const types = proto.WebMessageInfo.WEB_MESSAGE_INFO_STUBTYPE
|
||||
const dict: Record<number, string> = {}
|
||||
Object.keys(types).forEach(element => dict[ types[element] ] = element)
|
||||
return dict
|
||||
}()
|
||||
export const HKDFInfoKeys = {
|
||||
[MessageType.image]: 'WhatsApp Image Keys',
|
||||
[MessageType.audio]: 'WhatsApp Audio Keys',
|
||||
@@ -100,7 +94,7 @@ export interface MessageStatusUpdate {
|
||||
/** Message IDs read/delivered */
|
||||
ids: string[]
|
||||
/** Status of the Message IDs */
|
||||
type: proto.WebMessageInfo.WEB_MESSAGE_INFO_STATUS
|
||||
type: proto.WebMessageInfo.WEB_MESSAGE_INFO_STUBTYPE
|
||||
}
|
||||
export interface PresenceUpdate {
|
||||
id: string
|
||||
@@ -134,6 +128,16 @@ export interface WALocationMessage {
|
||||
degreesLongitude: number
|
||||
address?: string
|
||||
}
|
||||
export const WA_MESSAGE_STUB_TYPE = proto.WebMessageInfo.WEB_MESSAGE_INFO_STUBTYPE
|
||||
export const WA_MESSAGE_STATUS_TYPE = proto.WebMessageInfo.WEB_MESSAGE_INFO_STATUS
|
||||
|
||||
/** Reverse stub type dictionary */
|
||||
export const WAMessageType = function () {
|
||||
const types = WA_MESSAGE_STUB_TYPE
|
||||
const dict: Record<number, string> = {}
|
||||
Object.keys(types).forEach(element => dict[ types[element] ] = element)
|
||||
return dict
|
||||
}()
|
||||
export type WAContactMessage = proto.ContactMessage
|
||||
export type WAMessageKey = proto.IMessageKey
|
||||
export type WATextMessage = proto.ExtendedTextMessage
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class WhatsAppWebGroups extends WhatsAppWebBase {
|
||||
/** Get the metadata of the group */
|
||||
groupMetadata = (jid: string) => this.queryExpecting200(['query', 'GroupMetadata', jid]) as Promise<WAGroupMetadata>
|
||||
/** Get the metadata (works after you've left the group also) */
|
||||
groupCreatorAndParticipants = async (jid: string) => {
|
||||
groupMetadataMinimal = async (jid: string) => {
|
||||
const query = ['query', {type: 'group', jid: jid, epoch: this.msgCount.toString()}, null]
|
||||
const response = await this.queryExpecting200(query, [WAMetric.group, WAFlag.ignore])
|
||||
const json = response[2][0]
|
||||
|
||||
@@ -55,8 +55,15 @@ export default class WhatsAppWebMessages extends WhatsAppWebGroups {
|
||||
}
|
||||
return this.setQuery ([['read', attributes, null]])
|
||||
}
|
||||
/** Mark a given chat as unread */
|
||||
/**
|
||||
* Mark a given chat as unread
|
||||
* @deprecated since 2.0.0, use `sendReadReceipt (jid, null, 'unread')` instead
|
||||
*/
|
||||
async markChatUnread (jid: string) { return this.sendReadReceipt (jid, null, 'unread') }
|
||||
/**
|
||||
* Archive a chat
|
||||
* @deprecated since 2.0.0, use `modifyChat (jid, ChatModification.archive)` instead
|
||||
*/
|
||||
async archiveChat (jid: string) { return this.modifyChat (jid, ChatModification.archive) }
|
||||
/**
|
||||
* Modify a given chat (archive, pin etc.)
|
||||
|
||||
@@ -182,7 +182,7 @@ WAClientTest('Groups', (client) => {
|
||||
})
|
||||
it('should leave the group', async () => {
|
||||
await client.groupLeave(gid)
|
||||
await client.groupCreatorAndParticipants (gid)
|
||||
await client.groupMetadataMinimal (gid)
|
||||
})
|
||||
it('should archive the group', async () => {
|
||||
await client.archiveChat(gid)
|
||||
|
||||
@@ -19,7 +19,10 @@ export function validateJIDForSending (jid: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Type of notification */
|
||||
/**
|
||||
* Type of notification
|
||||
* @deprecated use WA_MESSAGE_STUB_TYPE instead
|
||||
* */
|
||||
export function getNotificationType(message: WAMessage): [string, MessageType?] {
|
||||
if (message.message) {
|
||||
return ['message', Object.keys(message.message)[0] as MessageType]
|
||||
|
||||
@@ -92,7 +92,6 @@ export enum WAFlag {
|
||||
}
|
||||
/** Tag used with binary queries */
|
||||
export type WATag = [WAMetric, WAFlag]
|
||||
export * as WAMessageProto from '../../WAMessage/WAMessage'
|
||||
|
||||
export * as WAMessageProto from '../../WAMessage/WAMessage'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user