Built motion from commit (unavailable).|2.2.5
[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 _0xe674=['ChatQueue,\x20%s,\x20%s,\x20%s','error','ChatQueue,\x20%s,\x20%s','message','result','GetChatQueue','ChatQueue','findAll','options','raw','where','attributes','limit','map','include','model','stringify','catch','ShowChatQueue','find','lodash','util','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./chatQueue.socket','request','then','info','request\x20sent','debug'];(function(_0x5211e6,_0x4800a0){var _0x457f44=function(_0x3d4c84){while(--_0x3d4c84){_0x5211e6['push'](_0x5211e6['shift']());}};_0x457f44(++_0x4800a0);}(_0xe674,0xf8));var _0x4e67=function(_0x51360d,_0x5a50cf){_0x51360d=_0x51360d-0x0;var _0x201a92=_0xe674[_0x51360d];return _0x201a92;};'use strict';var _=require(_0x4e67('0x0'));var util=require(_0x4e67('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x4e67('0x2'));var db=require(_0x4e67('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x4e67('0x4'));var config=require(_0x4e67('0x5'));var jayson=require(_0x4e67('0x6'));var client=jayson[_0x4e67('0x7')][_0x4e67('0x8')]({'port':0x232a});config[_0x4e67('0x9')]=_['defaults'](config[_0x4e67('0x9')],{'host':_0x4e67('0xa'),'port':0x18eb});var socket=require(_0x4e67('0xb'))(new Redis(config[_0x4e67('0x9')]));require(_0x4e67('0xc'))['register'](socket);function respondWithRpcPromise(_0x3b89fb,_0x30214e,_0x518b43){return new BPromise(function(_0x1be272,_0xf46e94){return client[_0x4e67('0xd')](_0x3b89fb,_0x518b43)[_0x4e67('0xe')](function(_0x1ebfdf){logger[_0x4e67('0xf')]('ChatQueue,\x20%s,\x20%s',_0x30214e,_0x4e67('0x10'));logger[_0x4e67('0x11')](_0x4e67('0x12'),_0x30214e,_0x4e67('0x10'),JSON['stringify'](_0x1ebfdf));if(_0x1ebfdf[_0x4e67('0x13')]){if(_0x1ebfdf[_0x4e67('0x13')]['code']===0x1f4){logger['error'](_0x4e67('0x14'),_0x30214e,_0x1ebfdf[_0x4e67('0x13')][_0x4e67('0x15')]);return _0xf46e94(_0x1ebfdf[_0x4e67('0x13')][_0x4e67('0x15')]);}logger[_0x4e67('0x13')](_0x4e67('0x14'),_0x30214e,_0x1ebfdf[_0x4e67('0x13')]['message']);return _0x1be272(_0x1ebfdf['error']['message']);}else{logger[_0x4e67('0xf')](_0x4e67('0x14'),_0x30214e,_0x4e67('0x10'));_0x1be272(_0x1ebfdf[_0x4e67('0x16')][_0x4e67('0x15')]);}})['catch'](function(_0x16d639){logger['error'](_0x4e67('0x14'),_0x30214e,_0x16d639);_0xf46e94(_0x16d639);});});}exports[_0x4e67('0x17')]=function(_0x52f9ac){var _0x553a76=this;return new Promise(function(_0x10df99,_0x3fb1c9){return db[_0x4e67('0x18')][_0x4e67('0x19')]({'raw':_0x52f9ac['options']?_0x52f9ac[_0x4e67('0x1a')][_0x4e67('0x1b')]===undefined?!![]:![]:!![],'where':_0x52f9ac[_0x4e67('0x1a')]?_0x52f9ac['options'][_0x4e67('0x1c')]||null:null,'attributes':_0x52f9ac[_0x4e67('0x1a')]?_0x52f9ac['options'][_0x4e67('0x1d')]||null:null,'limit':_0x52f9ac[_0x4e67('0x1a')]?_0x52f9ac['options'][_0x4e67('0x1e')]||null:null,'include':_0x52f9ac['options']?_0x52f9ac[_0x4e67('0x1a')]['include']?_[_0x4e67('0x1f')](_0x52f9ac[_0x4e67('0x1a')][_0x4e67('0x20')],function(_0x4c4e2d){return{'model':db[_0x4c4e2d['model']],'as':_0x4c4e2d['as'],'attributes':_0x4c4e2d[_0x4e67('0x1d')],'include':_0x4c4e2d[_0x4e67('0x20')]?_[_0x4e67('0x1f')](_0x4c4e2d[_0x4e67('0x20')],function(_0x1165a2){return{'model':db[_0x1165a2[_0x4e67('0x21')]],'as':_0x1165a2['as'],'attributes':_0x1165a2[_0x4e67('0x1d')],'include':_0x1165a2[_0x4e67('0x20')]?_[_0x4e67('0x1f')](_0x1165a2[_0x4e67('0x20')],function(_0x2bd3dd){return{'model':db[_0x2bd3dd['model']],'as':_0x2bd3dd['as'],'attributes':_0x2bd3dd[_0x4e67('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x4e67('0xe')](function(_0x3ed0ce){logger['info'](_0x4e67('0x17'),_0x52f9ac);logger['debug'](_0x4e67('0x17'),_0x52f9ac,JSON[_0x4e67('0x22')](_0x3ed0ce));_0x10df99(_0x3ed0ce);})[_0x4e67('0x23')](function(_0x5391ad){logger[_0x4e67('0x13')](_0x4e67('0x17'),_0x5391ad[_0x4e67('0x15')],_0x52f9ac);_0x3fb1c9(_0x553a76[_0x4e67('0x13')](0x1f4,_0x5391ad[_0x4e67('0x15')]));});});};exports[_0x4e67('0x24')]=function(_0x235187){var _0x184e0d=this;return new Promise(function(_0x531315,_0x291daa){return db[_0x4e67('0x18')][_0x4e67('0x25')]({'raw':_0x235187[_0x4e67('0x1a')]?_0x235187[_0x4e67('0x1a')][_0x4e67('0x1b')]===undefined?!![]:![]:!![],'where':_0x235187[_0x4e67('0x1a')]?_0x235187['options']['where']||null:null,'attributes':_0x235187[_0x4e67('0x1a')]?_0x235187['options'][_0x4e67('0x1d')]||null:null,'include':_0x235187[_0x4e67('0x1a')]?_0x235187[_0x4e67('0x1a')][_0x4e67('0x20')]?_[_0x4e67('0x1f')](_0x235187[_0x4e67('0x1a')][_0x4e67('0x20')],function(_0x438f49){return{'model':db[_0x438f49[_0x4e67('0x21')]],'as':_0x438f49['as'],'attributes':_0x438f49[_0x4e67('0x1d')],'include':_0x438f49[_0x4e67('0x20')]?_[_0x4e67('0x1f')](_0x438f49[_0x4e67('0x20')],function(_0x456e41){return{'model':db[_0x456e41['model']],'as':_0x456e41['as'],'attributes':_0x456e41['attributes'],'include':_0x456e41[_0x4e67('0x20')]?_['map'](_0x456e41[_0x4e67('0x20')],function(_0x5b3558){return{'model':db[_0x5b3558['model']],'as':_0x5b3558['as'],'attributes':_0x5b3558[_0x4e67('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x4e67('0xe')](function(_0xb401a9){logger[_0x4e67('0xf')](_0x4e67('0x24'),_0x235187);logger[_0x4e67('0x11')](_0x4e67('0x24'),_0x235187,JSON[_0x4e67('0x22')](_0xb401a9));_0x531315(_0xb401a9);})['catch'](function(_0x764bf2){logger[_0x4e67('0x13')](_0x4e67('0x24'),_0x764bf2[_0x4e67('0x15')],_0x235187);_0x291daa(_0x184e0d['error'](0x1f4,_0x764bf2['message']));});});};