Merge branch 'master' into master

This commit is contained in:
Samuel Scheit
2023-05-19 10:13:54 +02:00
committed by GitHub
14 changed files with 595 additions and 117 deletions

View File

@@ -1,6 +1,8 @@
import type { proto } from '../../WAProto'
import type { AccountSettings } from './Auth'
import type { BufferedEventData } from './Events'
import type { ChatLabelAssociationActionBody } from './LabelAssociation'
import type { MessageLabelAssociationActionBody } from './LabelAssociation'
import type { MinimalMessage } from './Message'
/** privacy settings in WhatsApp Web */
@@ -13,13 +15,7 @@ export type WAReadReceiptsValue = 'all' | 'none'
/** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused'
export const ALL_WA_PATCH_NAMES = [
'critical_block',
'critical_unblock_low',
'regular_high',
'regular_low',
'regular'
] as const
export const ALL_WA_PATCH_NAMES = ['critical_block', 'critical_unblock_low', 'regular_high', 'regular_low', 'regular'] as const
export type WAPatchName = typeof ALL_WA_PATCH_NAMES[number]
@@ -77,7 +73,7 @@ export type ChatModification =
mute: number | null
}
| {
clear: 'all' | { messages: {id: string, fromMe?: boolean, timestamp: number}[] }
clear: 'all' | { messages: { id: string, fromMe?: boolean, timestamp: number }[] }
}
| {
star: {
@@ -90,6 +86,11 @@ export type ChatModification =
lastMessages: LastMessageList
}
| { delete: true, lastMessages: LastMessageList }
// Label assosiation
| { addChatLabel: ChatLabelAssociationActionBody }
| { removeChatLabel: ChatLabelAssociationActionBody }
| { addMessageLabel: MessageLabelAssociationActionBody }
| { removeMessageLabel: MessageLabelAssociationActionBody }
export type InitialReceivedChatsState = {
[jid: string]: {

View File

@@ -5,6 +5,8 @@ import { WACallEvent } from './Call'
import { Chat, ChatUpdate, PresenceData } from './Chat'
import { Contact } from './Contact'
import { GroupMetadata, ParticipantAction } from './GroupMetadata'
import { Label } from './Label'
import { LabelAssociation } from './LabelAssociation'
import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message'
import { ConnectionState } from './State'
@@ -54,6 +56,8 @@ export type BaileysEventMap = {
'blocklist.update': { blocklist: string[], type: 'add' | 'remove' }
/** Receive an update on a call, including when the call was received, rejected, accepted */
'call': WACallEvent[]
'labels.edit': Label
'labels.association': { association: LabelAssociation, type: 'add' | 'remove' }
}
export type BufferedEventData = {

36
src/Types/Label.ts Normal file
View File

@@ -0,0 +1,36 @@
export interface Label {
/** Label uniq ID */
id: string
/** Label name */
name: string
/** Label color ID */
color: number
/** Is label has been deleted */
deleted: boolean
/** WhatsApp has 5 predefined labels (New customer, New order & etc) */
predefinedId?: string
}
/** WhatsApp has 20 predefined colors */
export enum LabelColor {
Color1 = 0,
Color2,
Color3,
Color4,
Color5,
Color6,
Color7,
Color8,
Color9,
Color10,
Color11,
Color12,
Color13,
Color14,
Color15,
Color16,
Color17,
Color18,
Color19,
Color20,
}

View File

@@ -0,0 +1,35 @@
/** Association type */
export enum LabelAssociationType {
Chat = 'label_jid',
Message = 'label_message'
}
export type LabelAssociationTypes = `${LabelAssociationType}`
/** Association for chat */
export interface ChatLabelAssociation {
type: LabelAssociationType.Chat
chatId: string
labelId: string
}
/** Association for message */
export interface MessageLabelAssociation {
type: LabelAssociationType.Message
chatId: string
messageId: string
labelId: string
}
export type LabelAssociation = ChatLabelAssociation | MessageLabelAssociation
/** Body for add/remove chat label association action */
export interface ChatLabelAssociationActionBody {
labelId: string
}
/** body for add/remove message label association action */
export interface MessageLabelAssociationActionBody {
labelId: string
messageId: string
}