[NEW] REST API Endpoint to get pinned messages from a room (#13864)

pull/14655/head^2
Thayanne Luiza 6 years ago committed by Diego Sampaio
parent f7ce6ac0dd
commit af88653152
  1. 31
      app/api/server/v1/chat.js
  2. 12
      tests/data/chat.helper.js
  3. 1184
      tests/end-to-end/api/05-chat.js

@ -392,6 +392,37 @@ API.v1.addRoute('chat.getDeletedMessages', { authRequired: true }, {
},
});
API.v1.addRoute('chat.getPinnedMessages', { authRequired: true }, {
get() {
const { roomId } = this.queryParams;
const { offset, count } = this.getPaginationItems();
if (!roomId) {
throw new Meteor.Error('error-roomId-param-not-provided', 'The required "roomId" query param is missing.');
}
const room = Meteor.call('canAccessRoom', roomId, this.userId);
if (!room) {
throw new Meteor.Error('error-not-allowed', 'Not allowed');
}
const cursor = Messages.findPinnedByRoom(room._id, {
skip: offset,
limit: count,
});
const total = cursor.count();
const messages = cursor.fetch();
return API.v1.success({
messages,
count: messages.length,
offset,
total,
});
},
});
API.v1.addRoute('chat.getThreadsList', { authRequired: true }, {
get() {
const { rid } = this.queryParams;

@ -17,6 +17,18 @@ export const sendSimpleMessage = ({ roomId, text = 'test message', tmid }) => {
.send({ message });
};
export const pinMessage = ({ msgId }) => {
if (!msgId) {
throw new Error('"msgId" is required in "pinMessage" test helper');
}
return request.post(api('chat.pinMessage'))
.set(credentials)
.send({
messageId: msgId,
});
};
export const deleteMessage = ({ roomId, msgId }) => {
if (!roomId) {
throw new Error('"roomId" is required in "deleteMessage" test helper');

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save