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
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
import { escapeRegExp } from '@rocket.chat/string-helpers';
import LivechatTag from '@rocket.chat/models';
import { LivechatTag } from '@rocket.chat/models';
import { ILivechatTag } from '@rocket.chat/core-typings';

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

export async function findTags({ userId, text, pagination: { offset, count, sort } }) {
type FindTagsParams = {
userId: string;
text: string;
pagination: {
offset: number;
count: number;
sort: object;
};
};

type FindTagsResult = {
tags: ILivechatTag[];
count: number;
offset: number;
total: number;
};

type FindTagsByIdParams = {
userId: string;
tagId: string;
};

type FindTagsByIdResult = ILivechatTag | null;

export async function findTags({ userId, text, pagination: { offset, count, sort } }: FindTagsParams): Promise<FindTagsResult> {
if (!(await hasPermissionAsync(userId, 'manage-livechat-tags')) && !(await hasPermissionAsync(userId, 'view-l-room'))) {
throw new Error('error-not-authorized');
}
Expand All @@ -28,7 +53,7 @@ export async function findTags({ userId, text, pagination: { offset, count, sort
};
}

export async function findTagById({ userId, tagId }) {
export async function findTagById({ userId, tagId }: FindTagsByIdParams): Promise<FindTagsByIdResult> {
if (!(await hasPermissionAsync(userId, 'manage-livechat-tags')) && !(await hasPermissionAsync(userId, 'view-l-room'))) {
throw new Error('error-not-authorized');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ API.v1.addRoute(
pagination: {
offset,
count,
sort,
sort: JSON.parse(sort || '{}'),
},
}),
),
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/ee/server/models/raw/LivechatTag.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { IRocketChatRecord } from '@rocket.chat/core-typings';
import { ILivechatTag } from '@rocket.chat/core-typings';
import type { ILivechatTagModel } from '@rocket.chat/model-typings';
import { getCollectionName } from '@rocket.chat/models';
import { Db } from 'mongodb';

import { BaseRaw } from '../../../../server/models/raw/BaseRaw';

export class LivechatTagRaw extends BaseRaw<IRocketChatRecord> implements ILivechatTagModel {
export class LivechatTagRaw extends BaseRaw<ILivechatTag> implements ILivechatTagModel {
constructor(db: Db) {
super(db, getCollectionName('livechat_tag'));
}
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/server/services/omnichannel-voip/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export class OmnichannelVoipService extends ServiceClassInternal implements IOmn

this.logger.debug(`Room ${room._id} closed and timers set`);
this.logger.debug(`Room ${room._id} was closed at ${closeInfo.closedAt} (duration ${closeInfo.callDuration})`);
VoipRoom.closeByRoomId(room._id, closeInfo);
await VoipRoom.closeByRoomId(room._id, closeInfo);

return true;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/model-typings/src/models/ILivechatTagModel.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { IRocketChatRecord } from '@rocket.chat/core-typings';
import type { ILivechatTag } from '@rocket.chat/core-typings';

import type { IBaseModel } from './IBaseModel';

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ILivechatTagModel extends IBaseModel<IRocketChatRecord> {
export interface ILivechatTagModel extends IBaseModel<ILivechatTag> {
//
}