diff --git a/packages/rocketchat-api/server/v1/emoji-custom.js b/packages/rocketchat-api/server/v1/emoji-custom.js index e8041e0a6291..65b9ea6fc8fd 100644 --- a/packages/rocketchat-api/server/v1/emoji-custom.js +++ b/packages/rocketchat-api/server/v1/emoji-custom.js @@ -3,7 +3,8 @@ import { RocketChat } from 'meteor/rocketchat:lib'; RocketChat.API.v1.addRoute('emoji-custom', { authRequired: true }, { get() { - const emojis = Meteor.call('listEmojiCustom'); + const { query } = this.parseJsonQuery(); + const emojis = Meteor.call('listEmojiCustom', query); return RocketChat.API.v1.success({ emojis }); }, diff --git a/packages/rocketchat-emoji-custom/server/methods/listEmojiCustom.js b/packages/rocketchat-emoji-custom/server/methods/listEmojiCustom.js index 55a9bd6afc65..3556275adf3e 100644 --- a/packages/rocketchat-emoji-custom/server/methods/listEmojiCustom.js +++ b/packages/rocketchat-emoji-custom/server/methods/listEmojiCustom.js @@ -2,7 +2,7 @@ import { Meteor } from 'meteor/meteor'; import { RocketChat } from 'meteor/rocketchat:lib'; Meteor.methods({ - listEmojiCustom() { - return RocketChat.models.EmojiCustom.find({}).fetch(); + listEmojiCustom(options) { + return RocketChat.models.EmojiCustom.find(options).fetch(); }, }); diff --git a/tests/end-to-end/api/12-emoji-custom.js b/tests/end-to-end/api/12-emoji-custom.js index 0b21c4b8a379..21891c70b1bf 100644 --- a/tests/end-to-end/api/12-emoji-custom.js +++ b/tests/end-to-end/api/12-emoji-custom.js @@ -8,8 +8,8 @@ describe('[EmojiCustom]', function() { before((done) => getCredentials(done)); - describe('GET', () => { - it('[/emoji-custom]', (done) => { + describe('[/emoji-custom]', () => { + it('should return emojis', (done) => { request.get(api('emoji-custom')) .set(credentials) .expect(200) @@ -18,5 +18,14 @@ describe('[EmojiCustom]', function() { }) .end(done); }); + it('should return emojis when use "query" query parameter', (done) => { + request.get(api('emoji-custom?query={"_updatedAt": {"$gt": { "$date": "2018-11-27T13:52:01Z" } }}')) + .set(credentials) + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('emojis').and.to.be.a('array'); + }) + .end(done); + }); }); });