[FIX] Omnichannel Inquiry queues when removing chats (#16603)

* Fix Inquiry stream when removing omnichannel rooms.

* Remove unnecessary blank line.

* Remove unnecessary import files.
pull/16637/head
Renato Becker 5 years ago committed by GitHub
parent f86323f346
commit 566ff2d3ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/livechat/client/lib/stream/queueManager.js
  2. 4
      app/livechat/client/views/app/livechatReadOnly.js
  3. 15
      app/livechat/server/lib/Livechat.js
  4. 8
      app/livechat/server/methods/removeAllClosedRooms.js
  5. 7
      app/livechat/server/methods/removeRoom.js
  6. 8
      app/models/server/models/LivechatInquiry.js

@ -15,12 +15,12 @@ const events = {
},
changed: (inquiry, collection) => {
if (inquiry.status !== 'queued' || (inquiry.department && !agentDepartments.includes(inquiry.department))) {
return collection.remove({ rid: inquiry.rid });
return collection.remove(inquiry._id);
}
delete inquiry.type;
collection.upsert({ rid: inquiry.rid }, inquiry);
collection.upsert({ _id: inquiry._id }, inquiry);
},
removed: (inquiry, collection) => collection.remove({ rid: inquiry.rid }),
removed: (inquiry, collection) => collection.remove(inquiry._id),
};
const appendListenerToDepartment = (departmentId, collection) => livechatQueueStreamer.on(`${ LIVECHAT_INQUIRY_QUEUE_STREAM_OBSERVER }/${ departmentId }`, (inquiry) => events[inquiry.type](inquiry, collection));

@ -50,9 +50,7 @@ Template.livechatReadOnly.onCreated(function() {
this.preparing = new ReactiveVar(true);
this.updateInquiry = (inquiry) => {
if (inquiry && inquiry.rid === this.rid) {
this.inquiry.set(inquiry);
}
this.inquiry.set(inquiry);
};
Meteor.call('livechat:getRoutingConfig', (err, config) => {

@ -370,6 +370,20 @@ export const Livechat = {
return true;
},
removeRoom(rid) {
check(rid, String);
const room = LivechatRooms.findOneById(rid);
if (!room) {
throw new Meteor.Error('error-invalid-room', 'Invalid room', { method: 'livechat:removeRoom' });
}
Messages.removeByRoomId(rid);
Subscriptions.removeByRoomId(rid);
LivechatInquiry.removeByRoomId(rid);
return LivechatRooms.removeById(rid);
},
setCustomFields({ token, key, value, overwrite } = {}) {
check(token, String);
check(key, String);
@ -757,6 +771,7 @@ export const Livechat = {
Subscriptions.removeByVisitorToken(token);
LivechatRooms.removeByVisitorToken(token);
LivechatInquiry.removeByVisitorToken(token);
},
saveDepartmentAgents(_id, departmentAgents) {

@ -1,7 +1,8 @@
import { Meteor } from 'meteor/meteor';
import { hasPermission } from '../../../authorization';
import { LivechatRooms, Messages, Subscriptions } from '../../../models';
import { LivechatRooms } from '../../../models';
import { Livechat } from '../lib/Livechat';
Meteor.methods({
'livechat:removeAllClosedRooms'(departmentIds) {
@ -11,10 +12,7 @@ Meteor.methods({
let count = 0;
LivechatRooms.findClosedRooms(departmentIds).forEach(({ _id }) => {
Messages.removeByRoomId(_id);
Subscriptions.removeByRoomId(_id);
LivechatRooms.removeById(_id);
Livechat.removeRoom(_id);
count++;
});

@ -1,7 +1,8 @@
import { Meteor } from 'meteor/meteor';
import { hasPermission } from '../../../authorization';
import { LivechatRooms, Messages, Subscriptions } from '../../../models';
import { LivechatRooms } from '../../../models';
import { Livechat } from '../lib/Livechat';
Meteor.methods({
'livechat:removeRoom'(rid) {
@ -29,8 +30,6 @@ Meteor.methods({
});
}
Messages.removeByRoomId(rid);
Subscriptions.removeByRoomId(rid);
return LivechatRooms.removeById(rid);
return Livechat.removeRoom(rid);
},
});

@ -172,6 +172,14 @@ export class LivechatInquiry extends Base {
removeByRoomId(rid) {
return this.remove({ rid });
}
removeByVisitorToken(token) {
const query = {
'v.token': token,
};
this.remove(query);
}
}
export default new LivechatInquiry();

Loading…
Cancel
Save