Built motion from commit (unavailable).|2.4.4
[motion2.git] / server / config / schedule / chat.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xf008=['../../config/environment','redis','defaults','localhost','socket.io-emitter','Setting','find','chatTimeout','then','ChatInteraction','lastMsgAt','subtract','minutes','update','system','timeout','YYYY-MM-DD\x20HH:mm:ss','map','length','emit','chatInteraction:update','catch','error','start','lodash','moment','ioredis'];(function(_0x42cae2,_0x284ef8){var _0x5f256f=function(_0x41abc8){while(--_0x41abc8){_0x42cae2['push'](_0x42cae2['shift']());}};_0x5f256f(++_0x284ef8);}(_0xf008,0x1c8));var _0x8f00=function(_0xec623c,_0x2d1fdb){_0xec623c=_0xec623c-0x0;var _0x148207=_0xf008[_0xec623c];return _0x148207;};'use strict';var _=require(_0x8f00('0x0'));var moment=require(_0x8f00('0x1'));var Redis=require(_0x8f00('0x2'));var db=require('../../mysqldb')['db'];var config=require(_0x8f00('0x3'));config[_0x8f00('0x4')]=_[_0x8f00('0x5')](config[_0x8f00('0x4')],{'host':_0x8f00('0x6'),'port':0x18eb});var io=require(_0x8f00('0x7'))(new Redis(config[_0x8f00('0x4')]));function closeInteractions(){var _0x7668ed=0x0;var _0x4aec62=[];return db[_0x8f00('0x8')][_0x8f00('0x9')]({'raw':!![],'attributes':['id',_0x8f00('0xa')],'where':{'id':0x1}})[_0x8f00('0xb')](function(_0x4f2182){_0x7668ed=_0x4f2182[_0x8f00('0xa')];if(_0x7668ed){return db[_0x8f00('0xc')]['findAll']({'raw':!![],'attributes':['id',_0x8f00('0xd')],'where':{'closed':![],'lastMsgAt':{'$lt':moment()[_0x8f00('0xe')](_0x4f2182['chatTimeout'],_0x8f00('0xf'))}}});}else{return[];}})[_0x8f00('0xb')](function(_0x1c2e69){_0x4aec62=_0x1c2e69;if(_0x7668ed){return db['ChatInteraction'][_0x8f00('0x10')]({'closeReason':_0x8f00('0x11'),'disposition':_0x8f00('0x12'),'closed':!![],'closedAt':moment()['format'](_0x8f00('0x13'))},{'where':{'id':_[_0x8f00('0x14')](_0x4aec62||[],'id')}});}})[_0x8f00('0xb')](function(_0x3d2fc5){for(var _0x4b9e23=0x0;_0x4b9e23<_0x4aec62[_0x8f00('0x15')];_0x4b9e23++){io[_0x8f00('0x16')](_0x8f00('0x17'),{'id':_0x4aec62[_0x4b9e23]['id'],'closed':!![]});}})[_0x8f00('0x18')](function(_0x49553a){console[_0x8f00('0x19')](_0x49553a);});}exports[_0x8f00('0x1a')]=function(){setInterval(function(){return closeInteractions();},0x3c*0x3e8);return closeInteractions();};