Skip to content

Commit 78ec10d

Browse files
committed
Revert "Corrigindo um bug no endpoint de findChats e permitindo paginação nos endpoints de findChats e findContacts"
This reverts commit a6482c8.
1 parent a6482c8 commit 78ec10d

2 files changed

Lines changed: 3 additions & 22 deletions

File tree

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,8 +1223,7 @@ export class BaileysStartupService extends ChannelStartupService {
12231223
existingChat &&
12241224
received.pushName &&
12251225
existingChat.name !== received.pushName &&
1226-
received.pushName.trim().length > 0 &&
1227-
!received.key.remoteJid.includes('@g.us')
1226+
received.pushName.trim().length > 0
12281227
) {
12291228
this.sendDataWebhook(Events.CHATS_UPSERT, [{ ...existingChat, name: received.pushName }]);
12301229
if (this.configService.get<Database>('DATABASE').SAVE_DATA.CHATS) {

src/api/services/channel.service.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -503,17 +503,9 @@ export class ChannelStartupService {
503503
where['remoteJid'] = remoteJid;
504504
}
505505

506-
const contactFindManyArgs: Prisma.ContactFindManyArgs = {
506+
return await this.prismaRepository.contact.findMany({
507507
where,
508-
};
509-
510-
if (query.offset) contactFindManyArgs.take = query.offset;
511-
if (query.page) {
512-
const validPage = Math.max(query.page as number, 1);
513-
contactFindManyArgs.skip = query.offset * (validPage - 1);
514-
}
515-
516-
return await this.prismaRepository.contact.findMany(contactFindManyArgs);
508+
});
517509
}
518510

519511
public cleanMessageData(message: any) {
@@ -682,13 +674,6 @@ export class ChannelStartupService {
682674
: createJid(query.where?.remoteJid)
683675
: null;
684676

685-
const limit =
686-
query.offset && !query.page
687-
? Prisma.sql` LIMIT ${query.offset}`
688-
: query.offset && query.page
689-
? Prisma.sql` LIMIT ${query.offset} OFFSET ${((query.page as number) - 1) * query.offset}`
690-
: Prisma.sql``;
691-
692677
const where = {
693678
instanceId: this.instanceId,
694679
};
@@ -715,7 +700,6 @@ export class ChannelStartupService {
715700
to_timestamp("Message"."messageTimestamp"::double precision),
716701
"Contact"."updatedAt"
717702
) as "updatedAt",
718-
"Chat"."name" as "chatName",
719703
"Chat"."createdAt" as "windowStart",
720704
"Chat"."createdAt" + INTERVAL '24 hours' as "windowExpires",
721705
CASE
@@ -746,7 +730,6 @@ export class ChannelStartupService {
746730
ORDER BY
747731
"Contact"."remoteJid",
748732
"Message"."messageTimestamp" DESC
749-
${limit}
750733
)
751734
SELECT * FROM rankedMessages
752735
ORDER BY "updatedAt" DESC NULLS LAST;
@@ -775,7 +758,6 @@ export class ChannelStartupService {
775758
id: contact.id,
776759
remoteJid: contact.remoteJid,
777760
pushName: contact.pushName,
778-
chatName: contact.chatName,
779761
profilePicUrl: contact.profilePicUrl,
780762
updatedAt: contact.updatedAt,
781763
windowStart: contact.windowStart,

0 commit comments

Comments
 (0)