fix: set participant.pn if available
This commit is contained in:
1 parent
5e75d47149
commit
78aea9aa51
4 files changed
+18
-5
No files matched your search
@@ -4,7 +4,7 @@ import {
|
||||
GroupInfoFull,
|
||||
JoinedGroupEvent,
|
||||
} from '@waha/core/engines/gows/types.group';
|
||||
import { toCusFormat, toJID } from '@waha/core/utils/jids';
|
||||
import { isPnUser, toCusFormat, toJID } from '@waha/core/utils/jids';
|
||||
import {
|
||||
GroupId,
|
||||
GroupInfo,
|
||||
@@ -115,8 +115,10 @@ function getParticipants(jids: string[] | null, type: GroupParticipantType) {
|
||||
}
|
||||
const participants: GroupParticipant[] = [];
|
||||
for (const jid of jids) {
|
||||
const id = toCusFormat(jid);
|
||||
participants.push({
|
||||
id: toCusFormat(jid),
|
||||
id: id,
|
||||
pn: isPnUser(id) ? id : null,
|
||||
role: role,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
GroupV2ParticipantsEvent,
|
||||
GroupV2UpdateEvent,
|
||||
} from '@waha/structures/groups.events.dto';
|
||||
import { toCusFormat } from '@waha/core/utils/jids';
|
||||
import { isPnUser, toCusFormat } from '@waha/core/utils/jids';
|
||||
import esm from '@waha/vendor/esm';
|
||||
|
||||
export function ToGroupInfo(group: Partial<GroupMetadata>): GroupInfo {
|
||||
@@ -77,6 +77,15 @@ export function getParticipantId(
|
||||
return participant?.id;
|
||||
}
|
||||
|
||||
function getParticipantPn(
|
||||
participant: string | NOWEBGroupParticipant,
|
||||
): string | null {
|
||||
if (typeof participant === 'string') {
|
||||
return isPnUser(participant) ? participant : null;
|
||||
}
|
||||
return participant?.phoneNumber || null;
|
||||
}
|
||||
|
||||
function getParticipantIds(
|
||||
participant: string | NOWEBGroupParticipant,
|
||||
): string[] {
|
||||
@@ -129,6 +138,7 @@ export function ToGroupV2Participants(
|
||||
const id = getParticipantId(item);
|
||||
return {
|
||||
id: toCusFormat(id),
|
||||
pn: toCusFormat(getParticipantPn(item)),
|
||||
role: role,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -140,6 +140,7 @@ export function ToGroupV2ParticipantsEvent(
|
||||
(id) => {
|
||||
return {
|
||||
id: id,
|
||||
pn: isPnUser(id) ? id : null,
|
||||
role: role,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { toCusFormat } from '@waha/core/utils/jids';
|
||||
import { isPnUser, toCusFormat } from '@waha/core/utils/jids';
|
||||
import { SerializeMsgKey } from '@waha/core/utils/ids';
|
||||
import { WAMessageReaction } from '@waha/structures/responses.dto';
|
||||
import { WAHAPresenceStatus } from '@waha/structures/enums.dto';
|
||||
@@ -109,7 +109,7 @@ export function WppParticipantsToGroupV2Participants(
|
||||
const group: GroupId = { id: toCusFormat(data.groupId) };
|
||||
const participants: GroupParticipant[] = data.who.map((id) => ({
|
||||
id: id,
|
||||
pn: null,
|
||||
pn: isPnUser(id) ? id : null,
|
||||
role: role,
|
||||
}));
|
||||
|
||||
|
||||
Reference in new issue
Block a user