messages-send,jid-utils: get deterministic server for user

This commit is contained in:
Rajeh Taher
2025-10-08 02:46:09 +03:00
parent e9198b773e
commit c41aae78c2
2 changed files with 18 additions and 2 deletions
+14
View File
@@ -34,6 +34,20 @@ export type FullJid = JidWithDevice & {
domainType?: number
}
export const getServerFromDomainType = (initialServer: string, domainType?: WAJIDDomains): JidServer => {
switch(domainType) {
case WAJIDDomains.LID:
return 'lid'
case WAJIDDomains.HOSTED:
return 'hosted'
case WAJIDDomains.HOSTED_LID:
return 'hosted.lid'
case WAJIDDomains.WHATSAPP:
default:
return initialServer
}
}
export const jidEncode = (user: string | number | null, server: JidServer, device?: number, agent?: number) => {
return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server}`
}