@whiskeysockets/baileys
Version:
A WebSockets library for interacting with WhatsApp Web
52 lines • 1.33 kB
JavaScript
import { assertNodeErrorFree } from '../../WABinary/index.js';
import { USyncUser } from '../USyncUser.js';
export class USyncContactProtocol {
constructor() {
this.name = 'contact';
}
getQueryElement() {
return {
tag: 'contact',
attrs: {}
};
}
getUserElement(user) {
if (user.phone) {
return {
tag: 'contact',
attrs: {},
content: user.phone
};
}
if (user.username) {
return {
tag: 'contact',
attrs: {
username: user.username,
...(user.usernameKey ? { pin: user.usernameKey } : {}),
...(user.lid ? { lid: user.lid } : {})
}
};
}
if (user.type) {
return {
tag: 'contact',
attrs: {
type: user.type
}
};
}
return {
tag: 'contact',
attrs: {}
};
}
parser(node) {
if (node.tag === 'contact') {
assertNodeErrorFree(node);
return node?.attrs?.type === 'in';
}
return false;
}
}
//# sourceMappingURL=USyncContactProtocol.js.map