Skip to content

Commit bedfb01

Browse files
committed
fix lint
1 parent fb1fa4d commit bedfb01

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,8 @@ export class BaileysStartupService extends ChannelStartupService {
500500
try {
501501
// Use raw SQL to avoid JSON path issues
502502
const webMessageInfo = (await this.prismaRepository.$queryRaw`
503-
SELECT * FROM "Message"
504-
WHERE "instanceId" = ${this.instanceId}
503+
SELECT * FROM "Message"
504+
WHERE "instanceId" = ${this.instanceId}
505505
AND "key"->>'id' = ${key.id}
506506
`) as proto.IWebMessageInfo[];
507507

@@ -1491,8 +1491,8 @@ export class BaileysStartupService extends ChannelStartupService {
14911491
if (configDatabaseData.HISTORIC || configDatabaseData.NEW_MESSAGE) {
14921492
// Use raw SQL to avoid JSON path issues
14931493
const messages = (await this.prismaRepository.$queryRaw`
1494-
SELECT * FROM "Message"
1495-
WHERE "instanceId" = ${this.instanceId}
1494+
SELECT * FROM "Message"
1495+
WHERE "instanceId" = ${this.instanceId}
14961496
AND "key"->>'id' = ${key.id}
14971497
LIMIT 1
14981498
`) as any[];
@@ -1600,33 +1600,33 @@ export class BaileysStartupService extends ChannelStartupService {
16001600
// MAINTAINS: participants: string[] (original JID strings)
16011601
// ADDS: participantsData: { jid: string, phoneNumber: string, name?: string, imgUrl?: string }[]
16021602
// This enables LID to phoneNumber conversion without breaking existing webhook consumers
1603-
1603+
16041604
// Helper to normalize participantId as phone number
16051605
const normalizePhoneNumber = (id: string): string => {
16061606
// Remove @lid, @s.whatsapp.net suffixes and extract just the number part
16071607
return id.split('@')[0];
16081608
};
1609-
1609+
16101610
try {
1611-
// Usa o mesmo método que o endpoint /group/participants
1611+
// Usa o mesmo método que o endpoint /group/participants
16121612
const groupParticipants = await this.findParticipants({ groupJid: participantsUpdate.id });
1613-
1613+
16141614
// Validação para garantir que temos dados válidos
16151615
if (!groupParticipants?.participants || !Array.isArray(groupParticipants.participants)) {
16161616
throw new Error('Invalid participant data received from findParticipants');
16171617
}
1618-
1618+
16191619
// Filtra apenas os participantes que estão no evento
16201620
const resolvedParticipants = participantsUpdate.participants.map((participantId) => {
1621-
const participantData = groupParticipants.participants.find(p => p.id === participantId);
1622-
1621+
const participantData = groupParticipants.participants.find((p) => p.id === participantId);
1622+
16231623
let phoneNumber: string;
16241624
if (participantData?.phoneNumber) {
16251625
phoneNumber = participantData.phoneNumber;
16261626
} else {
16271627
phoneNumber = normalizePhoneNumber(participantId);
16281628
}
1629-
1629+
16301630
return {
16311631
jid: participantId,
16321632
phoneNumber,
@@ -1639,13 +1639,14 @@ export class BaileysStartupService extends ChannelStartupService {
16391639
const enhancedParticipantsUpdate = {
16401640
...participantsUpdate,
16411641
participants: participantsUpdate.participants, // Mantém array original de strings
1642-
participantsData: resolvedParticipants // Adiciona dados resolvidos em campo separado
1642+
// Adiciona dados resolvidos em campo separado
1643+
participantsData: resolvedParticipants,
16431644
};
1644-
1645+
16451646
this.sendDataWebhook(Events.GROUP_PARTICIPANTS_UPDATE, enhancedParticipantsUpdate);
16461647
} catch (error) {
16471648
this.logger.error(
1648-
`Failed to resolve participant data for GROUP_PARTICIPANTS_UPDATE webhook: ${error.message} | Group: ${participantsUpdate.id} | Participants: ${participantsUpdate.participants.length}`
1649+
`Failed to resolve participant data for GROUP_PARTICIPANTS_UPDATE webhook: ${error.message} | Group: ${participantsUpdate.id} | Participants: ${participantsUpdate.participants.length}`,
16491650
);
16501651
// Fallback - envia sem conversão
16511652
this.sendDataWebhook(Events.GROUP_PARTICIPANTS_UPDATE, participantsUpdate);
@@ -4514,7 +4515,7 @@ export class BaileysStartupService extends ChannelStartupService {
45144515

45154516
// Use raw SQL to avoid JSON path issues
45164517
const result = await this.prismaRepository.$executeRaw`
4517-
UPDATE "Message"
4518+
UPDATE "Message"
45184519
SET "status" = ${status[4]}
45194520
WHERE "instanceId" = ${this.instanceId}
45204521
AND "key"->>'remoteJid' = ${remoteJid}
@@ -4539,7 +4540,7 @@ export class BaileysStartupService extends ChannelStartupService {
45394540
this.prismaRepository.chat.findFirst({ where: { remoteJid } }),
45404541
// Use raw SQL to avoid JSON path issues
45414542
this.prismaRepository.$queryRaw`
4542-
SELECT COUNT(*)::int as count FROM "Message"
4543+
SELECT COUNT(*)::int as count FROM "Message"
45434544
WHERE "instanceId" = ${this.instanceId}
45444545
AND "key"->>'remoteJid' = ${remoteJid}
45454546
AND ("key"->>'fromMe')::boolean = false

0 commit comments

Comments
 (0)