Revert "feat: add inbound username support and USync username protocol (#382)"
This reverts commit d08a09c35f.
This commit is contained in:
@@ -343,13 +343,11 @@ export const extractGroupMetadata = (result: BinaryNode) => {
|
||||
let descId: string | undefined
|
||||
let descOwner: string | undefined
|
||||
let descOwnerPn: string | undefined
|
||||
let descOwnerUsername: string | undefined
|
||||
let descTime: number | undefined
|
||||
if (descChild) {
|
||||
desc = getBinaryNodeChildString(descChild, 'body')
|
||||
descOwner = descChild.attrs.participant ? jidNormalizedUser(descChild.attrs.participant) : undefined
|
||||
descOwnerPn = descChild.attrs.participant_pn ? jidNormalizedUser(descChild.attrs.participant_pn) : undefined
|
||||
descOwnerUsername = descChild.attrs.participant_username || undefined
|
||||
descTime = +descChild.attrs.t!
|
||||
descId = descChild.attrs.id
|
||||
}
|
||||
@@ -364,19 +362,16 @@ export const extractGroupMetadata = (result: BinaryNode) => {
|
||||
subject: group.attrs.subject!,
|
||||
subjectOwner: group.attrs.s_o,
|
||||
subjectOwnerPn: group.attrs.s_o_pn,
|
||||
subjectOwnerUsername: group.attrs.s_o_username,
|
||||
subjectTime: +(group.attrs.s_t ?? '0'),
|
||||
size: group.attrs.size ? +group.attrs.size : getBinaryNodeChildren(group, 'participant').length,
|
||||
creation: +(group.attrs.creation ?? '0'),
|
||||
owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined,
|
||||
ownerPn: group.attrs.creator_pn ? jidNormalizedUser(group.attrs.creator_pn) : undefined,
|
||||
ownerUsername: group.attrs.creator_username || undefined,
|
||||
owner_country_code: group.attrs.creator_country_code,
|
||||
desc,
|
||||
descId,
|
||||
descOwner,
|
||||
descOwnerPn,
|
||||
descOwnerUsername,
|
||||
descTime,
|
||||
linkedParent: getBinaryNodeChild(group, 'linked_parent')?.attrs.jid || undefined,
|
||||
restrict: !!getBinaryNodeChild(group, 'locked'),
|
||||
@@ -391,7 +386,6 @@ export const extractGroupMetadata = (result: BinaryNode) => {
|
||||
id: attrs.jid!,
|
||||
phoneNumber: isLidUser(attrs.jid) && isPnUser(attrs.phone_number) ? attrs.phone_number : undefined,
|
||||
lid: isPnUser(attrs.jid) && isLidUser(attrs.lid) ? attrs.lid : undefined,
|
||||
username: attrs.participant_username || attrs.username || undefined,
|
||||
admin: (attrs.type || null) as GroupParticipant['admin']
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -2240,7 +2240,6 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
fromMe,
|
||||
participant: node.attrs.participant,
|
||||
participantAlt,
|
||||
participantUsername: node.attrs.participant_username,
|
||||
addressingMode,
|
||||
id: node.attrs.id,
|
||||
...(msg.key || {})
|
||||
@@ -2249,10 +2248,6 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
msg.messageTimestamp = +node.attrs.t!
|
||||
|
||||
const fullMsg = proto.WebMessageInfo.fromObject(msg) as WAMessage
|
||||
// Preserve custom WAMessageKey fields (participantAlt, participantUsername,
|
||||
// addressingMode) that proto.WebMessageInfo.fromObject strips because
|
||||
// they aren't part of the proto.MessageKey schema.
|
||||
fullMsg.key = msg.key
|
||||
await upsertMessage(fullMsg, 'append')
|
||||
}
|
||||
})
|
||||
|
||||
@@ -9,8 +9,6 @@ export interface Contact {
|
||||
name?: string
|
||||
/** name of the contact, the contact has set on their own on WA */
|
||||
notify?: string
|
||||
/** username associated with this contact, when provided by WA */
|
||||
username?: string
|
||||
/** I have no idea */
|
||||
verifiedName?: string
|
||||
// Baileys Added
|
||||
|
||||
@@ -81,7 +81,6 @@ export type BaileysEventMap = {
|
||||
id: string
|
||||
author: string
|
||||
authorPn?: string
|
||||
authorUsername?: string
|
||||
participants: GroupParticipant[]
|
||||
action: ParticipantAction
|
||||
}
|
||||
@@ -89,7 +88,6 @@ export type BaileysEventMap = {
|
||||
id: string
|
||||
author: string
|
||||
authorPn?: string
|
||||
authorUsername?: string
|
||||
participant: string
|
||||
participantPn?: string
|
||||
action: RequestJoinAction
|
||||
|
||||
@@ -20,20 +20,17 @@ export interface GroupMetadata {
|
||||
addressingMode?: WAMessageAddressingMode
|
||||
owner: string | undefined
|
||||
ownerPn?: string | undefined
|
||||
ownerUsername?: string | undefined
|
||||
owner_country_code?: string | undefined
|
||||
subject: string
|
||||
/** group subject owner */
|
||||
subjectOwner?: string
|
||||
subjectOwnerPn?: string
|
||||
subjectOwnerUsername?: string
|
||||
/** group subject modification date */
|
||||
subjectTime?: number
|
||||
creation?: number
|
||||
desc?: string
|
||||
descOwner?: string
|
||||
descOwnerPn?: string
|
||||
descOwnerUsername?: string
|
||||
descId?: string
|
||||
descTime?: number
|
||||
/** if this group is part of a community, it returns the jid of the community to which it belongs */
|
||||
@@ -59,7 +56,6 @@ export interface GroupMetadata {
|
||||
/** the person who added you to group or changed some setting in group */
|
||||
author?: string
|
||||
authorPn?: string
|
||||
authorUsername?: string
|
||||
}
|
||||
|
||||
export interface WAGroupCreateResponse {
|
||||
|
||||
@@ -19,9 +19,7 @@ export type WAContactMessage = proto.Message.IContactMessage
|
||||
export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage
|
||||
export type WAMessageKey = proto.IMessageKey & {
|
||||
remoteJidAlt?: string
|
||||
remoteJidUsername?: string
|
||||
participantAlt?: string
|
||||
participantUsername?: string
|
||||
server_id?: string
|
||||
addressingMode?: string
|
||||
isViewOnce?: boolean // TODO: remove out of the message key, place in WebMessageInfo
|
||||
|
||||
@@ -1083,7 +1083,6 @@ export const processSyncAction = (
|
||||
action.lidContactAction.firstName ||
|
||||
action.lidContactAction.username ||
|
||||
undefined,
|
||||
username: action.lidContactAction.username || undefined,
|
||||
lid: id!,
|
||||
phoneNumber: undefined
|
||||
}
|
||||
|
||||
@@ -246,14 +246,10 @@ export function decodeMessageNode(stanza: BinaryNode, meId: string, meLid: strin
|
||||
const key: WAMessageKey = {
|
||||
remoteJid: chatId,
|
||||
remoteJidAlt: !isJidGroup(chatId) ? addressingContext.senderAlt : undefined,
|
||||
remoteJidUsername: !isJidGroup(chatId)
|
||||
? stanza.attrs.peer_recipient_username || stanza.attrs.recipient_username
|
||||
: undefined,
|
||||
fromMe,
|
||||
id: msgId,
|
||||
participant,
|
||||
participantAlt: isJidGroup(chatId) ? addressingContext.senderAlt : undefined,
|
||||
participantUsername: stanza.attrs.participant ? stanza.attrs.participant_username : undefined,
|
||||
addressingMode: addressingContext.addressingMode,
|
||||
...(msgType === 'newsletter' && stanza.attrs.server_id ? { server_id: stanza.attrs.server_id } : {})
|
||||
}
|
||||
|
||||
@@ -315,7 +315,6 @@ export const processHistoryMessage = (item: proto.IHistorySync, logger?: ILogger
|
||||
contacts.push({
|
||||
id: chatId,
|
||||
name: chat.displayName || chat.name || chat.username || undefined,
|
||||
username: chat.username || undefined,
|
||||
lid: chat.lidJid || chat.accountLid || undefined,
|
||||
phoneNumber: chat.pnJid || undefined
|
||||
})
|
||||
|
||||
@@ -950,19 +950,12 @@ const processMessage = async (
|
||||
id: jid,
|
||||
author: message.key.participant!,
|
||||
authorPn: message.key.participantAlt!,
|
||||
authorUsername: message.key.participantUsername!,
|
||||
participants,
|
||||
action
|
||||
})
|
||||
const emitGroupUpdate = (update: Partial<GroupMetadata>) => {
|
||||
ev.emit('groups.update', [
|
||||
{
|
||||
id: jid,
|
||||
...update,
|
||||
author: message.key.participant ?? undefined,
|
||||
authorPn: message.key.participantAlt,
|
||||
authorUsername: message.key.participantUsername
|
||||
}
|
||||
{ id: jid, ...update, author: message.key.participant ?? undefined, authorPn: message.key.participantAlt }
|
||||
])
|
||||
}
|
||||
|
||||
@@ -971,7 +964,6 @@ const processMessage = async (
|
||||
id: jid,
|
||||
author: message.key.participant!,
|
||||
authorPn: message.key.participantAlt!,
|
||||
authorUsername: message.key.participantUsername!,
|
||||
participant: participant.lid,
|
||||
participantPn: participant.pn,
|
||||
action,
|
||||
|
||||
@@ -46,7 +46,6 @@ export const processContactAction = (
|
||||
{
|
||||
id,
|
||||
name: action.fullName || action.firstName || action.username || undefined,
|
||||
username: action.username || undefined,
|
||||
lid: lidJid || undefined,
|
||||
phoneNumber
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export class USyncContactProtocol implements USyncQueryProtocol {
|
||||
}
|
||||
|
||||
getUserElement(user: USyncUser): BinaryNode {
|
||||
if (user.phone) {
|
||||
//TODO: Implement type / username fields (not yet supported)
|
||||
return {
|
||||
tag: 'contact',
|
||||
attrs: {},
|
||||
@@ -21,32 +21,6 @@ export class USyncContactProtocol implements USyncQueryProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
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: BinaryNode): boolean {
|
||||
if (node.tag === 'contact') {
|
||||
assertNodeErrorFree(node)
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
import type { USyncQueryProtocol } from '../../Types/USync'
|
||||
import { assertNodeErrorFree, type BinaryNode } from '../../WABinary'
|
||||
import { USyncUser } from '../USyncUser'
|
||||
|
||||
export class USyncUsernameProtocol implements USyncQueryProtocol {
|
||||
name = 'username'
|
||||
|
||||
getQueryElement(): BinaryNode {
|
||||
return {
|
||||
tag: 'username',
|
||||
attrs: {}
|
||||
}
|
||||
}
|
||||
|
||||
getUserElement(user: USyncUser): BinaryNode | null {
|
||||
void user
|
||||
return null
|
||||
}
|
||||
|
||||
parser(node: BinaryNode): string | null {
|
||||
if (node.tag === 'username') {
|
||||
assertNodeErrorFree(node)
|
||||
return typeof node.content === 'string' ? node.content : null
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -2,4 +2,3 @@ export * from './USyncDeviceProtocol'
|
||||
export * from './USyncContactProtocol'
|
||||
export * from './USyncStatusProtocol'
|
||||
export * from './USyncDisappearingModeProtocol'
|
||||
export * from './USyncUsernameProtocol'
|
||||
|
||||
@@ -6,8 +6,7 @@ import {
|
||||
USyncContactProtocol,
|
||||
USyncDeviceProtocol,
|
||||
USyncDisappearingModeProtocol,
|
||||
USyncStatusProtocol,
|
||||
USyncUsernameProtocol
|
||||
USyncStatusProtocol
|
||||
} from './Protocols'
|
||||
import { USyncUser } from './USyncUser'
|
||||
|
||||
@@ -138,9 +137,4 @@ export class USyncQuery {
|
||||
this.protocols.push(new USyncLIDProtocol())
|
||||
return this
|
||||
}
|
||||
|
||||
withUsernameProtocol() {
|
||||
this.protocols.push(new USyncUsernameProtocol())
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ export class USyncUser {
|
||||
id?: string
|
||||
lid?: string
|
||||
phone?: string
|
||||
username?: string
|
||||
usernameKey?: string
|
||||
type?: string
|
||||
personaId?: string
|
||||
|
||||
@@ -22,16 +20,6 @@ export class USyncUser {
|
||||
return this
|
||||
}
|
||||
|
||||
withUsername(username: string) {
|
||||
this.username = username
|
||||
return this
|
||||
}
|
||||
|
||||
withUsernameKey(usernameKey: string) {
|
||||
this.usernameKey = usernameKey
|
||||
return this
|
||||
}
|
||||
|
||||
withType(type: string) {
|
||||
this.type = type
|
||||
return this
|
||||
|
||||
Reference in New Issue
Block a user