Files
InfiniteAPI/src/WAUSync/Protocols/USyncContactProtocol.ts
T
Rajeh Taher f1f49ad2c8 Usync: Barebones Usync Protocol support (#960)
* feature(feature/usync-mex): initial commit

* chore: fix merge commit

* chore:lint
2024-12-22 23:38:41 +02:00

32 lines
676 B
TypeScript

import { USyncQueryProtocol } from '../../Types/USync'
import { assertNodeErrorFree, BinaryNode } from '../../WABinary'
import { USyncUser } from '../USyncUser'
export class USyncContactProtocol implements USyncQueryProtocol {
name = 'contact'
getQueryElement(): BinaryNode {
return {
tag: 'contact',
attrs: {},
}
}
getUserElement(user: USyncUser): BinaryNode {
//TODO: Implement type / username fields (not yet supported)
return {
tag: 'contact',
attrs: {},
content: user.phone,
}
}
parser(node: BinaryNode): boolean {
if(node.tag === 'contact') {
assertNodeErrorFree(node)
return node?.attrs?.type === 'in'
}
return false
}
}