The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/ee/server/api/chat.ts

47 lines
1.2 KiB

import type { IMessage, IReadReceiptWithUser } from '@rocket.chat/core-typings';
import { License } from '@rocket.chat/license';
import { Meteor } from 'meteor/meteor';
import { API } from '../../../app/api/server/api';
import { getReadReceiptsFunction } from '../methods/getReadReceipts';
type GetMessageReadReceiptsProps = {
messageId: IMessage['_id'];
};
declare module '@rocket.chat/rest-typings' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface Endpoints {
'/v1/chat.getMessageReadReceipts': {
GET: (params: GetMessageReadReceiptsProps) => {
receipts: IReadReceiptWithUser[];
};
};
}
}
API.v1.addRoute(
'chat.getMessageReadReceipts',
{
authRequired: true,
// license: ['message-read-receipt']
},
{
async get() {
if (!License.hasModule('message-read-receipt')) {
throw new Meteor.Error('error-action-not-allowed', 'This is an enterprise feature');
}
const { messageId } = this.queryParams;
if (!messageId) {
return API.v1.failure({
error: "The required 'messageId' param is missing.",
});
}
return API.v1.success({
receipts: await getReadReceiptsFunction(messageId, this.userId),
});
},
},
);