feat: add contextInfo support

This commit is contained in:
Hisoka775
2023-06-09 06:04:55 +08:00
committed by Edgard
parent 226d9af66c
commit 13c3b91852
2 changed files with 15 additions and 5 deletions

View File

@@ -52,6 +52,10 @@ type Mentionable = {
/** list of jids that are mentioned in the accompanying text */ /** list of jids that are mentioned in the accompanying text */
mentions?: string[] mentions?: string[]
} }
type Contextable = {
/** add contextInfo to the message */
contextInfo?: proto.IContextInfo
}
type ViewOnce = { type ViewOnce = {
viewOnce?: boolean viewOnce?: boolean
} }
@@ -98,13 +102,13 @@ export type AnyMediaMessageContent = (
image: WAMediaUpload image: WAMediaUpload
caption?: string caption?: string
jpegThumbnail?: string jpegThumbnail?: string
} & Mentionable & Buttonable & Templatable & WithDimensions) } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions)
| ({ | ({
video: WAMediaUpload video: WAMediaUpload
caption?: string caption?: string
gifPlayback?: boolean gifPlayback?: boolean
jpegThumbnail?: string jpegThumbnail?: string
} & Mentionable & Buttonable & Templatable & WithDimensions) } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions)
| { | {
audio: WAMediaUpload audio: WAMediaUpload
/** if set to true, will send as a `voice note` */ /** if set to true, will send as a `voice note` */
@@ -120,7 +124,7 @@ export type AnyMediaMessageContent = (
mimetype: string mimetype: string
fileName?: string fileName?: string
caption?: string caption?: string
} & Buttonable & Templatable)) } & Contextable & Buttonable & Templatable))
& { mimetype?: string } & Editable & { mimetype?: string } & Editable
export type ButtonReplyInfo = { export type ButtonReplyInfo = {
@@ -138,11 +142,11 @@ export type AnyRegularMessageContent = (
text: string text: string
linkPreview?: WAUrlInfo | null linkPreview?: WAUrlInfo | null
} }
& Mentionable & Buttonable & Templatable & Listable & Editable) & Mentionable & Contextable & Buttonable & Templatable & Listable & Editable)
| AnyMediaMessageContent | AnyMediaMessageContent
| ({ | ({
poll: PollMessageOptions poll: PollMessageOptions
} & Mentionable & Buttonable & Templatable & Editable) } & Mentionable & Contextable & Buttonable & Templatable & Editable)
| { | {
contacts: { contacts: {
displayName?: string displayName?: string

View File

@@ -498,6 +498,12 @@ export const generateWAMessageContent = async(
} }
} }
if('contextInfo' in message && !!message.contextInfo) {
const [messageType] = Object.keys(m)
m[messageType] = m[messageType] || {}
m[messageType].contextInfo = message.contextInfo
}
return WAProto.Message.fromObject(m) return WAProto.Message.fromObject(m)
} }