Built motion from commit 97f2f211.|2.6.31
[motion2.git] / server / api / chatQueue / chatQueue.rpc.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 _0x530f=['redis','defaults','localhost','socket.io-emitter','./chatQueue.socket','register','request','then','request\x20sent','debug','ChatQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','ChatQueue,\x20%s,\x20%s','message','result','GetChatQueue','ChatQueue','findAll','options','where','attributes','limit','include','map','model','info','catch','ShowChatQueue','find','util','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http'];(function(_0x3e2b07,_0x32c3f1){var _0x5812ad=function(_0x40f1b7){while(--_0x40f1b7){_0x3e2b07['push'](_0x3e2b07['shift']());}};_0x5812ad(++_0x32c3f1);}(_0x530f,0x167));var _0xf530=function(_0x32a81f,_0x4eee66){_0x32a81f=_0x32a81f-0x0;var _0x5b67a2=_0x530f[_0x32a81f];return _0x5b67a2;};'use strict';var _=require('lodash');var util=require(_0xf530('0x0'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xf530('0x1'));var fs=require('fs');var Redis=require(_0xf530('0x2'));var db=require(_0xf530('0x3'))['db'];var utils=require(_0xf530('0x4'));var logger=require(_0xf530('0x5'))(_0xf530('0x6'));var config=require(_0xf530('0x7'));var jayson=require(_0xf530('0x8'));var client=jayson['client'][_0xf530('0x9')]({'port':0x232a});config[_0xf530('0xa')]=_[_0xf530('0xb')](config['redis'],{'host':_0xf530('0xc'),'port':0x18eb});var socket=require(_0xf530('0xd'))(new Redis(config[_0xf530('0xa')]));require(_0xf530('0xe'))[_0xf530('0xf')](socket);function respondWithRpcPromise(_0x1b3603,_0x4b8336,_0xd747c3){return new BPromise(function(_0x2fd24d,_0x383493){return client[_0xf530('0x10')](_0x1b3603,_0xd747c3)[_0xf530('0x11')](function(_0x39912f){logger['info']('ChatQueue,\x20%s,\x20%s',_0x4b8336,_0xf530('0x12'));logger[_0xf530('0x13')](_0xf530('0x14'),_0x4b8336,_0xf530('0x12'),JSON[_0xf530('0x15')](_0x39912f));if(_0x39912f['error']){if(_0x39912f[_0xf530('0x16')][_0xf530('0x17')]===0x1f4){logger[_0xf530('0x16')](_0xf530('0x18'),_0x4b8336,_0x39912f[_0xf530('0x16')][_0xf530('0x19')]);return _0x383493(_0x39912f[_0xf530('0x16')][_0xf530('0x19')]);}logger['error'](_0xf530('0x18'),_0x4b8336,_0x39912f[_0xf530('0x16')]['message']);return _0x2fd24d(_0x39912f[_0xf530('0x16')][_0xf530('0x19')]);}else{logger['info'](_0xf530('0x18'),_0x4b8336,_0xf530('0x12'));_0x2fd24d(_0x39912f[_0xf530('0x1a')][_0xf530('0x19')]);}})['catch'](function(_0x34742c){logger[_0xf530('0x16')](_0xf530('0x18'),_0x4b8336,_0x34742c);_0x383493(_0x34742c);});});}exports[_0xf530('0x1b')]=function(_0x2bd710){var _0x3cb0f7=this;return new Promise(function(_0x48f834,_0x3f47ad){return db[_0xf530('0x1c')][_0xf530('0x1d')]({'raw':_0x2bd710[_0xf530('0x1e')]?_0x2bd710[_0xf530('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x2bd710['options']?_0x2bd710['options'][_0xf530('0x1f')]||null:null,'attributes':_0x2bd710[_0xf530('0x1e')]?_0x2bd710[_0xf530('0x1e')][_0xf530('0x20')]||null:null,'limit':_0x2bd710[_0xf530('0x1e')]?_0x2bd710['options'][_0xf530('0x21')]||null:null,'include':_0x2bd710[_0xf530('0x1e')]?_0x2bd710[_0xf530('0x1e')][_0xf530('0x22')]?_[_0xf530('0x23')](_0x2bd710[_0xf530('0x1e')][_0xf530('0x22')],function(_0x148ebe){return{'model':db[_0x148ebe[_0xf530('0x24')]],'as':_0x148ebe['as'],'attributes':_0x148ebe[_0xf530('0x20')],'include':_0x148ebe[_0xf530('0x22')]?_['map'](_0x148ebe[_0xf530('0x22')],function(_0x1471eb){return{'model':db[_0x1471eb[_0xf530('0x24')]],'as':_0x1471eb['as'],'attributes':_0x1471eb['attributes'],'include':_0x1471eb[_0xf530('0x22')]?_['map'](_0x1471eb['include'],function(_0x3108d){return{'model':db[_0x3108d[_0xf530('0x24')]],'as':_0x3108d['as'],'attributes':_0x3108d[_0xf530('0x20')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xf1c4f2){logger[_0xf530('0x25')](_0xf530('0x1b'),_0x2bd710);logger[_0xf530('0x13')](_0xf530('0x1b'),_0x2bd710,JSON[_0xf530('0x15')](_0xf1c4f2));_0x48f834(_0xf1c4f2);})[_0xf530('0x26')](function(_0x439951){logger[_0xf530('0x16')](_0xf530('0x1b'),_0x439951['message'],_0x2bd710);_0x3f47ad(_0x3cb0f7[_0xf530('0x16')](0x1f4,_0x439951['message']));});});};exports[_0xf530('0x27')]=function(_0x14ce26){var _0x4d60ad=this;return new Promise(function(_0x5e082c,_0x588856){return db[_0xf530('0x1c')][_0xf530('0x28')]({'raw':_0x14ce26[_0xf530('0x1e')]?_0x14ce26[_0xf530('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x14ce26['options']?_0x14ce26[_0xf530('0x1e')][_0xf530('0x1f')]||null:null,'attributes':_0x14ce26[_0xf530('0x1e')]?_0x14ce26[_0xf530('0x1e')][_0xf530('0x20')]||null:null,'include':_0x14ce26[_0xf530('0x1e')]?_0x14ce26[_0xf530('0x1e')]['include']?_[_0xf530('0x23')](_0x14ce26[_0xf530('0x1e')][_0xf530('0x22')],function(_0x1375de){return{'model':db[_0x1375de[_0xf530('0x24')]],'as':_0x1375de['as'],'attributes':_0x1375de['attributes'],'include':_0x1375de[_0xf530('0x22')]?_['map'](_0x1375de[_0xf530('0x22')],function(_0x53c95a){return{'model':db[_0x53c95a[_0xf530('0x24')]],'as':_0x53c95a['as'],'attributes':_0x53c95a[_0xf530('0x20')],'include':_0x53c95a[_0xf530('0x22')]?_[_0xf530('0x23')](_0x53c95a['include'],function(_0x44bd4d){return{'model':db[_0x44bd4d['model']],'as':_0x44bd4d['as'],'attributes':_0x44bd4d['attributes']};}):[]};}):[]};}):[]:[]})[_0xf530('0x11')](function(_0x3c6c96){logger[_0xf530('0x25')](_0xf530('0x27'),_0x14ce26);logger[_0xf530('0x13')](_0xf530('0x27'),_0x14ce26,JSON[_0xf530('0x15')](_0x3c6c96));_0x5e082c(_0x3c6c96);})[_0xf530('0x26')](function(_0x2d6fd2){logger[_0xf530('0x16')](_0xf530('0x27'),_0x2d6fd2[_0xf530('0x19')],_0x14ce26);_0x588856(_0x4d60ad['error'](0x1f4,_0x2d6fd2[_0xf530('0x19')]));});});};