Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Add possibility to set room closer to LivechatUpdater.closeRoom #391

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
4 changes: 3 additions & 1 deletion src/definition/accessors/ILivechatUpdater.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ILivechatTransferData, IVisitor } from '../livechat';
import { IRoom } from '../rooms';
import { IUser } from '../users';

export interface ILivechatUpdater {
/**
Expand All @@ -15,8 +16,9 @@ export interface ILivechatUpdater {
*
* @param room The room to be closed
* @param comment The comment explaining the reason for closing the room
* @param closer The user that closes the room
*/
closeRoom(room: IRoom, comment: string): Promise<boolean>;
closeRoom(room: IRoom, comment: string, closer?: IUser): Promise<boolean>;

/**
* Set a livechat visitor's custom fields by its token
Expand Down
5 changes: 3 additions & 2 deletions src/server/accessors/LivechatUpdater.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ILivechatUpdater } from '../../definition/accessors';
import { ILivechatRoom, ILivechatTransferData, IVisitor } from '../../definition/livechat';
import { IUser } from '../../definition/users';
import { AppBridges } from '../bridges';

export class LivechatUpdater implements ILivechatUpdater {
Expand All @@ -9,8 +10,8 @@ export class LivechatUpdater implements ILivechatUpdater {
return this.bridges.getLivechatBridge().doTransferVisitor(visitor, transferData, this.appId);
}

public closeRoom(room: ILivechatRoom, comment: string): Promise<boolean> {
return this.bridges.getLivechatBridge().doCloseRoom(room, comment, this.appId);
public closeRoom(room: ILivechatRoom, comment: string, closer?: IUser): Promise<boolean> {
return this.bridges.getLivechatBridge().doCloseRoom(room, comment, closer, this.appId);
}

public setCustomFields(token: IVisitor['token'], key: string, value: string, overwrite: boolean): Promise<boolean> {
Expand Down
6 changes: 3 additions & 3 deletions src/server/bridges/LivechatBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ export abstract class LivechatBridge extends BaseBridge {
}
}

public async doCloseRoom(room: ILivechatRoom, comment: string, appId: string): Promise<boolean> {
public async doCloseRoom(room: ILivechatRoom, comment: string, closer: IUser | undefined, appId: string): Promise<boolean> {
if (this.hasWritePermission(appId, 'livechat-room')) {
return this.closeRoom(room, comment, appId);
return this.closeRoom(room, comment, closer, appId);
}
}

Expand Down Expand Up @@ -174,7 +174,7 @@ export abstract class LivechatBridge extends BaseBridge {
protected abstract findVisitorByPhoneNumber(phoneNumber: string, appId: string): Promise<IVisitor | undefined>;
protected abstract transferVisitor(visitor: IVisitor, transferData: ILivechatTransferData, appId: string): Promise<boolean>;
protected abstract createRoom(visitor: IVisitor, agent: IUser, appId: string): Promise<ILivechatRoom>;
protected abstract closeRoom(room: ILivechatRoom, comment: string, appId: string): Promise<boolean>;
protected abstract closeRoom(room: ILivechatRoom, comment: string, closer: IUser | undefined, appId: string): Promise<boolean>;
protected abstract findRooms(visitor: IVisitor, departmentId: string | null, appId: string): Promise<Array<ILivechatRoom>>;
protected abstract findDepartmentByIdOrName(value: string, appId: string): Promise<IDepartment | undefined>;
protected abstract findDepartmentsEnabledWithAgents(appId: string): Promise<Array<IDepartment>>;
Expand Down
2 changes: 1 addition & 1 deletion tests/test-data/bridges/livechatBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class TestLivechatBridge extends LivechatBridge {
public createRoom(visitor: IVisitor, agent: IUser, appId: string): Promise<ILivechatRoom> {
throw new Error('Method not implemented');
}
public closeRoom(room: ILivechatRoom, comment: string, appId: string): Promise<boolean> {
public closeRoom(room: ILivechatRoom, comment: string, closer: IUser | undefined, appId: string): Promise<boolean> {
throw new Error('Method not implemented');
}
public findRooms(visitor: IVisitor, departmentId: string | null, appId: string): Promise<Array<ILivechatRoom>> {
Expand Down