diff --git a/apps/meteor/app/api/server/v1/im.ts b/apps/meteor/app/api/server/v1/im.ts index a749a2da9b1..509713cb289 100644 --- a/apps/meteor/app/api/server/v1/im.ts +++ b/apps/meteor/app/api/server/v1/im.ts @@ -434,7 +434,7 @@ API.v1.addRoute( .toArray(); const { cursor, totalCount } = Rooms.findPaginated( - { type: 'd', _id: { $in: subscriptions } }, + { t: 'd', _id: { $in: subscriptions } }, { sort, skip: offset, @@ -451,7 +451,7 @@ API.v1.addRoute( return API.v1.success({ ims, offset, - count, + count: ims.length, total, }); }, diff --git a/apps/meteor/tests/end-to-end/api/04-direct-message.js b/apps/meteor/tests/end-to-end/api/04-direct-message.js index 3610b073c34..cc041ee030e 100644 --- a/apps/meteor/tests/end-to-end/api/04-direct-message.js +++ b/apps/meteor/tests/end-to-end/api/04-direct-message.js @@ -188,8 +188,18 @@ describe('[Direct Messages]', function () { .expect(200) .expect((res) => { expect(res.body).to.have.property('success', true); - expect(res.body).to.have.property('count'); - expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('count', 1); + expect(res.body).to.have.property('total', 1); + expect(res.body).to.have.property('ims').and.to.be.an('array'); + const im = res.body.ims[0]; + expect(im).to.have.property('_id'); + expect(im).to.have.property('t').and.to.be.eq('d'); + expect(im).to.have.property('msgs').and.to.be.a('number'); + expect(im).to.have.property('usernames').and.to.be.an('array'); + expect(im).to.have.property('lm'); + expect(im).to.have.property('_updatedAt'); + expect(im).to.have.property('ts'); + expect(im).to.have.property('lastMessage'); }) .end(done); }); @@ -202,8 +212,19 @@ describe('[Direct Messages]', function () { .expect(200) .expect((res) => { expect(res.body).to.have.property('success', true); - expect(res.body).to.have.property('count'); - expect(res.body).to.have.property('total'); + expect(res.body).to.have.property('count', 1); + expect(res.body).to.have.property('total', 1); + expect(res.body).to.have.property('ims').and.to.be.an('array'); + const im = res.body.ims[0]; + expect(im).to.have.property('_id'); + expect(im).to.have.property('t').and.to.be.eq('d'); + expect(im).to.have.property('msgs').and.to.be.a('number'); + expect(im).to.have.property('usernames').and.to.be.an('array'); + expect(im).to.have.property('ro'); + expect(im).to.have.property('sysMes'); + expect(im).to.have.property('_updatedAt'); + expect(im).to.have.property('ts'); + expect(im).to.have.property('lastMessage'); }) .end(done); });