feat: send tctoken to profile update and presence subscribe (#2257)
* fix: improve message resend logic by adding checks for message IDs * Revert "fix: improve message resend logic by adding checks for message IDs" This reverts commit c03f9d8e6fc6cbfbb9d1f8f67c169700e704213d. * feat(tc-token): implement buildTcTokenFromJid utility and integrate into chats socket * fix(tc-token): ensure consistent return value when tcTokenBuffer is absent * fix(chats): update import path for buildTcTokenFromJid utility
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import type { AuthenticationCreds, SignalKeyStoreWithTransaction } from '../Types'
|
||||
import type { BinaryNode } from '../WABinary'
|
||||
|
||||
type TcTokenParams = {
|
||||
jid: string
|
||||
baseContent?: BinaryNode[]
|
||||
authState: {
|
||||
keys: SignalKeyStoreWithTransaction
|
||||
}
|
||||
}
|
||||
|
||||
export async function buildTcTokenFromJid({
|
||||
authState,
|
||||
jid,
|
||||
baseContent = []
|
||||
}: TcTokenParams): Promise<BinaryNode[] | undefined> {
|
||||
try {
|
||||
const tcTokenData = await authState.keys.get('tctoken', [jid])
|
||||
|
||||
const tcTokenBuffer = tcTokenData?.[jid]?.token
|
||||
|
||||
if (!tcTokenBuffer) return baseContent.length > 0 ? baseContent : undefined
|
||||
|
||||
baseContent.push({
|
||||
tag: 'tctoken',
|
||||
attrs: {},
|
||||
content: tcTokenBuffer
|
||||
})
|
||||
|
||||
return baseContent
|
||||
} catch (error) {
|
||||
return baseContent.length > 0 ? baseContent : undefined
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user