f1f49ad2c8
* feature(feature/usync-mex): initial commit * chore: fix merge commit * chore:lint
32 lines
676 B
TypeScript
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
|
|
}
|
|
} |