@@ -503,9 +503,14 @@ export class ChannelStartupService {
503503 where [ 'remoteJid' ] = remoteJid ;
504504 }
505505
506- return await this . prismaRepository . contact . findMany ( {
506+ const contactFindManyArgs : Prisma . ContactFindManyArgs = {
507507 where,
508- } ) ;
508+ } ;
509+
510+ if ( query . offset ) contactFindManyArgs . take = query . offset ;
511+ if ( query . page ) contactFindManyArgs . skip = query . offset * ( ( query . page as number ) - 1 ) ;
512+
513+ return await this . prismaRepository . contact . findMany ( contactFindManyArgs ) ;
509514 }
510515
511516 public cleanMessageData ( message : any ) {
@@ -674,6 +679,13 @@ export class ChannelStartupService {
674679 : createJid ( query . where ?. remoteJid )
675680 : null ;
676681
682+ const limit =
683+ query . offset && ! query . page
684+ ? Prisma . sql ` LIMIT ${ query . offset } `
685+ : query . offset && query . page
686+ ? Prisma . sql ` LIMIT ${ query . offset } OFFSET ${ ( ( query . page as number ) - 1 ) * query . offset } `
687+ : Prisma . sql `` ;
688+
677689 const where = {
678690 instanceId : this . instanceId ,
679691 } ;
@@ -700,6 +712,7 @@ export class ChannelStartupService {
700712 to_timestamp("Message"."messageTimestamp"::double precision),
701713 "Contact"."updatedAt"
702714 ) as "updatedAt",
715+ "Chat"."name" as "chatName",
703716 "Chat"."createdAt" as "windowStart",
704717 "Chat"."createdAt" + INTERVAL '24 hours' as "windowExpires",
705718 CASE
@@ -730,6 +743,7 @@ export class ChannelStartupService {
730743 ORDER BY
731744 "Contact"."remoteJid",
732745 "Message"."messageTimestamp" DESC
746+ ${ limit }
733747 )
734748 SELECT * FROM rankedMessages
735749 ORDER BY "updatedAt" DESC NULLS LAST;
@@ -758,6 +772,7 @@ export class ChannelStartupService {
758772 id : contact . id ,
759773 remoteJid : contact . remoteJid ,
760774 pushName : contact . pushName ,
775+ chatName : contact . chatName ,
761776 profilePicUrl : contact . profilePicUrl ,
762777 updatedAt : contact . updatedAt ,
763778 windowStart : contact . windowStart ,
0 commit comments