Skip to content

Commit

Permalink
Fix livechat view creation
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego committed Sep 1, 2020
1 parent a47314a commit 0d6d01f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/livechat/server/lib/Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,16 @@ export const createLivechatSubscription = (rid, name, guest, agent) => {
return Subscriptions.insert(subscriptionData);
};

export const createLivechatQueueView = () => {
export const createLivechatQueueView = async () => {
const { mongo } = MongoInternals.defaultRemoteCollectionDriver();

mongo.db.createCollection('view_livechat_queue_status', { // name of the view to create
// recreate the view on every startup
const list = await mongo.db.listCollections({ name: 'view_livechat_queue_status' }).toArray();
if (list.length > 0) {
await mongo.db.dropCollection('view_livechat_queue_status');
}

await mongo.db.createCollection('view_livechat_queue_status', { // name of the view to create
viewOn: 'rocketchat_room', // name of source collection from which to create the view
pipeline: [
{
Expand Down

0 comments on commit 0d6d01f

Please sign in to comment.