Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions apps/meteor/app/livechat/imports/server/rest/inquiries.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,16 @@ API.v1.addRoute(
'livechat/inquiries.getOne',
{ authRequired: true, permissionsRequired: ['view-l-room'] },
{
get() {
async get() {
const { roomId } = this.queryParams;
if (!roomId) {
return API.v1.failure("The 'roomId' param is required");
}

return API.v1.success(
Promise.await(
findOneInquiryByRoomId({
userId: this.userId,
roomId,
}),
),
await findOneInquiryByRoomId({
roomId,
}),
);
},
},
Expand Down
12 changes: 1 addition & 11 deletions apps/meteor/app/livechat/server/api/lib/inquiries.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { LivechatDepartmentAgents, LivechatDepartment, LivechatInquiry } from '@rocket.chat/models';

import { hasPermissionAsync } from '../../../../authorization/server/functions/hasPermission';

const agentDepartments = async (userId) => {
const agentDepartments = (await LivechatDepartmentAgents.findByAgentId(userId).toArray()).map(({ departmentId }) => departmentId);
return (await LivechatDepartment.find({ _id: { $in: agentDepartments }, enabled: true }).toArray()).map(({ _id }) => _id);
Expand All @@ -25,10 +23,6 @@ const applyDepartmentRestrictions = async (userId, filterDepartment) => {
};

export async function findInquiries({ userId, department: filterDepartment, status, pagination: { offset, count, sort } }) {
if (!(await hasPermissionAsync(userId, 'view-l-room'))) {
throw new Error('error-not-authorized');
}

const department = await applyDepartmentRestrictions(userId, filterDepartment);

const options = {
Expand Down Expand Up @@ -61,11 +55,7 @@ export async function findInquiries({ userId, department: filterDepartment, stat
};
}

export async function findOneInquiryByRoomId({ userId, roomId }) {
if (!(await hasPermissionAsync(userId, 'view-l-room'))) {
throw new Error('error-not-authorized');
}

export async function findOneInquiryByRoomId({ roomId }) {
return {
inquiry: await LivechatInquiry.findOneByRoomId(roomId),
};
Expand Down
1 change: 0 additions & 1 deletion apps/meteor/server/models/raw/LivechatRooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,6 @@ export class LivechatRoomsRaw extends BaseRaw {
params.push({ $limit: options.limit });
}

console.log('params', JSON.stringify(params, null, 2));
return this.col.aggregate(params);
}

Expand Down