@@ -330,9 +330,14 @@ export class ChannelStartupService {
330330 where [ 'remoteJid' ] = remoteJid ;
331331 }
332332
333- return await this . prismaRepository . contact . findMany ( {
333+ const contactFindManyArgs : Prisma . ContactFindManyArgs = {
334334 where,
335- } ) ;
335+ } ;
336+
337+ if ( query . offset ) contactFindManyArgs . take = query . offset ;
338+ if ( query . page ) contactFindManyArgs . skip = query . offset * ( ( query . page as number ) - 1 ) ;
339+
340+ return await this . prismaRepository . contact . findMany ( contactFindManyArgs ) ;
336341 }
337342
338343 public cleanMessageData ( message : any ) {
@@ -501,6 +506,13 @@ export class ChannelStartupService {
501506 : createJid ( query . where ?. remoteJid )
502507 : null ;
503508
509+ const limit =
510+ query . offset && ! query . page
511+ ? Prisma . sql ` LIMIT ${ query . offset } `
512+ : query . offset && query . page
513+ ? Prisma . sql ` LIMIT ${ query . offset } OFFSET ${ ( ( query . page as number ) - 1 ) * query . offset } `
514+ : Prisma . sql `` ;
515+
504516 const where = {
505517 instanceId : this . instanceId ,
506518 } ;
@@ -527,6 +539,7 @@ export class ChannelStartupService {
527539 to_timestamp("Message"."messageTimestamp"::double precision),
528540 "Contact"."updatedAt"
529541 ) as "updatedAt",
542+ "Chat"."name" as "chatName",
530543 "Chat"."createdAt" as "windowStart",
531544 "Chat"."createdAt" + INTERVAL '24 hours' as "windowExpires",
532545 CASE
@@ -557,6 +570,7 @@ export class ChannelStartupService {
557570 ORDER BY
558571 "Contact"."remoteJid",
559572 "Message"."messageTimestamp" DESC
573+ ${ limit }
560574 )
561575 SELECT * FROM rankedMessages
562576 ORDER BY "updatedAt" DESC NULLS LAST;
@@ -585,6 +599,7 @@ export class ChannelStartupService {
585599 id : contact . id ,
586600 remoteJid : contact . remoteJid ,
587601 pushName : contact . pushName ,
602+ chatName : contact . chatName ,
588603 profilePicUrl : contact . profilePicUrl ,
589604 updatedAt : contact . updatedAt ,
590605 windowStart : contact . windowStart ,
0 commit comments