Skip to content

Commit

Permalink
unarchiveDepartment
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman committed Oct 12, 2023
1 parent 2048242 commit 328bc2c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
7 changes: 2 additions & 5 deletions apps/meteor/app/livechat/imports/server/rest/departments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,8 @@ API.v1.addRoute(
},
{
async post() {
if (await Livechat.unarchiveDepartment(this.urlParams._id)) {
return API.v1.success();
}

return API.v1.failure();
await LivechatTs.unarchiveDepartment(this.urlParams._id);
return API.v1.success();
},
},
);
Expand Down
16 changes: 0 additions & 16 deletions apps/meteor/app/livechat/server/lib/Livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -717,22 +717,6 @@ export const Livechat = {
return ret;
},

async unarchiveDepartment(_id) {
check(_id, String);

const department = await LivechatDepartmentRaw.findOneById(_id, { projection: { _id: 1 } });

if (!department) {
throw new Meteor.Error('department-not-found', 'Department not found', {
method: 'livechat:removeDepartment',
});
}

// TODO: these kind of actions should be on events instead of here
await LivechatDepartmentAgents.enableAgentsByDepartmentId(_id);
return LivechatDepartmentRaw.unarchiveDepartment(_id);
},

showConnecting() {
const { showConnecting } = RoutingManager.getConfig();
return showConnecting;
Expand Down
12 changes: 12 additions & 0 deletions apps/meteor/app/livechat/server/lib/LivechatTyped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,18 @@ class LivechatClass {

await callbacks.run('livechat.afterDepartmentArchived', department);
}

async unarchiveDepartment(_id: string) {
const department = await LivechatDepartment.findOneById(_id, { projection: { _id: 1 } });

if (!department) {
throw new Meteor.Error('department-not-found');
}

// TODO: these kind of actions should be on events instead of here
await Promise.all([LivechatDepartmentAgents.enableAgentsByDepartmentId(_id), LivechatDepartment.unarchiveDepartment(_id)]);
return true;
}
}

export const Livechat = new LivechatClass();

0 comments on commit 328bc2c

Please sign in to comment.