Built motion from commit dbf3a7e2.|2.6.30
[motion2.git] / server / api / openchannelQueue / openchannelQueue.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 _0xa18f=['options','raw','attributes','include','map','model','stringify','catch','ShowOpenchannelQueue','OpenchannelQueue','find','util','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./openchannelQueue.socket','request','then','info','request\x20sent','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','error','message','OpenchannelQueue,\x20%s,\x20%s','GetOpenchannelQueue','findAll'];(function(_0x34bc30,_0x177cb0){var _0x5706de=function(_0x535a8c){while(--_0x535a8c){_0x34bc30['push'](_0x34bc30['shift']());}};_0x5706de(++_0x177cb0);}(_0xa18f,0x7a));var _0xfa18=function(_0x4c6aac,_0x5b2540){_0x4c6aac=_0x4c6aac-0x0;var _0x54dfc7=_0xa18f[_0x4c6aac];return _0x54dfc7;};'use strict';var _=require('lodash');var util=require(_0xfa18('0x0'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xfa18('0x1'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xfa18('0x2'))['db'];var utils=require(_0xfa18('0x3'));var logger=require(_0xfa18('0x4'))(_0xfa18('0x5'));var config=require(_0xfa18('0x6'));var jayson=require(_0xfa18('0x7'));var client=jayson[_0xfa18('0x8')][_0xfa18('0x9')]({'port':0x232a});config[_0xfa18('0xa')]=_[_0xfa18('0xb')](config['redis'],{'host':_0xfa18('0xc'),'port':0x18eb});var socket=require(_0xfa18('0xd'))(new Redis(config[_0xfa18('0xa')]));require(_0xfa18('0xe'))['register'](socket);function respondWithRpcPromise(_0x2c82ac,_0x4b6d46,_0x1f16ee){return new BPromise(function(_0x3eebb4,_0x5d32be){return client[_0xfa18('0xf')](_0x2c82ac,_0x1f16ee)[_0xfa18('0x10')](function(_0x25fbe4){logger[_0xfa18('0x11')]('OpenchannelQueue,\x20%s,\x20%s',_0x4b6d46,_0xfa18('0x12'));logger[_0xfa18('0x13')](_0xfa18('0x14'),_0x4b6d46,_0xfa18('0x12'),JSON['stringify'](_0x25fbe4));if(_0x25fbe4[_0xfa18('0x15')]){if(_0x25fbe4[_0xfa18('0x15')]['code']===0x1f4){logger[_0xfa18('0x15')]('OpenchannelQueue,\x20%s,\x20%s',_0x4b6d46,_0x25fbe4[_0xfa18('0x15')][_0xfa18('0x16')]);return _0x5d32be(_0x25fbe4[_0xfa18('0x15')][_0xfa18('0x16')]);}logger[_0xfa18('0x15')](_0xfa18('0x17'),_0x4b6d46,_0x25fbe4[_0xfa18('0x15')][_0xfa18('0x16')]);return _0x3eebb4(_0x25fbe4[_0xfa18('0x15')][_0xfa18('0x16')]);}else{logger['info'](_0xfa18('0x17'),_0x4b6d46,_0xfa18('0x12'));_0x3eebb4(_0x25fbe4['result']['message']);}})['catch'](function(_0x3408c2){logger['error'](_0xfa18('0x17'),_0x4b6d46,_0x3408c2);_0x5d32be(_0x3408c2);});});}exports[_0xfa18('0x18')]=function(_0x4b12dc){var _0x2a9c53=this;return new Promise(function(_0x18ec54,_0x58653d){return db['OpenchannelQueue'][_0xfa18('0x19')]({'raw':_0x4b12dc[_0xfa18('0x1a')]?_0x4b12dc[_0xfa18('0x1a')][_0xfa18('0x1b')]===undefined?!![]:![]:!![],'where':_0x4b12dc[_0xfa18('0x1a')]?_0x4b12dc['options']['where']||null:null,'attributes':_0x4b12dc['options']?_0x4b12dc['options'][_0xfa18('0x1c')]||null:null,'limit':_0x4b12dc[_0xfa18('0x1a')]?_0x4b12dc['options']['limit']||null:null,'include':_0x4b12dc[_0xfa18('0x1a')]?_0x4b12dc[_0xfa18('0x1a')][_0xfa18('0x1d')]?_[_0xfa18('0x1e')](_0x4b12dc['options'][_0xfa18('0x1d')],function(_0x4ce293){return{'model':db[_0x4ce293[_0xfa18('0x1f')]],'as':_0x4ce293['as'],'attributes':_0x4ce293['attributes'],'include':_0x4ce293[_0xfa18('0x1d')]?_[_0xfa18('0x1e')](_0x4ce293[_0xfa18('0x1d')],function(_0x2a2bbe){return{'model':db[_0x2a2bbe[_0xfa18('0x1f')]],'as':_0x2a2bbe['as'],'attributes':_0x2a2bbe[_0xfa18('0x1c')],'include':_0x2a2bbe[_0xfa18('0x1d')]?_[_0xfa18('0x1e')](_0x2a2bbe['include'],function(_0x56058f){return{'model':db[_0x56058f[_0xfa18('0x1f')]],'as':_0x56058f['as'],'attributes':_0x56058f['attributes']};}):[]};}):[]};}):[]:[]})[_0xfa18('0x10')](function(_0x2068a8){logger[_0xfa18('0x11')](_0xfa18('0x18'),_0x4b12dc);logger[_0xfa18('0x13')](_0xfa18('0x18'),_0x4b12dc,JSON[_0xfa18('0x20')](_0x2068a8));_0x18ec54(_0x2068a8);})[_0xfa18('0x21')](function(_0xd1d894){logger[_0xfa18('0x15')](_0xfa18('0x18'),_0xd1d894['message'],_0x4b12dc);_0x58653d(_0x2a9c53[_0xfa18('0x15')](0x1f4,_0xd1d894[_0xfa18('0x16')]));});});};exports[_0xfa18('0x22')]=function(_0x5c56f9){var _0x220fbd=this;return new Promise(function(_0x40ebd6,_0x16082f){return db[_0xfa18('0x23')][_0xfa18('0x24')]({'raw':_0x5c56f9['options']?_0x5c56f9[_0xfa18('0x1a')][_0xfa18('0x1b')]===undefined?!![]:![]:!![],'where':_0x5c56f9[_0xfa18('0x1a')]?_0x5c56f9[_0xfa18('0x1a')]['where']||null:null,'attributes':_0x5c56f9[_0xfa18('0x1a')]?_0x5c56f9[_0xfa18('0x1a')][_0xfa18('0x1c')]||null:null,'include':_0x5c56f9[_0xfa18('0x1a')]?_0x5c56f9[_0xfa18('0x1a')][_0xfa18('0x1d')]?_[_0xfa18('0x1e')](_0x5c56f9['options']['include'],function(_0x648da4){return{'model':db[_0x648da4[_0xfa18('0x1f')]],'as':_0x648da4['as'],'attributes':_0x648da4['attributes'],'include':_0x648da4['include']?_[_0xfa18('0x1e')](_0x648da4[_0xfa18('0x1d')],function(_0xf98c35){return{'model':db[_0xf98c35['model']],'as':_0xf98c35['as'],'attributes':_0xf98c35['attributes'],'include':_0xf98c35[_0xfa18('0x1d')]?_[_0xfa18('0x1e')](_0xf98c35[_0xfa18('0x1d')],function(_0x2f077d){return{'model':db[_0x2f077d[_0xfa18('0x1f')]],'as':_0x2f077d['as'],'attributes':_0x2f077d[_0xfa18('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xfa18('0x10')](function(_0x2222ab){logger[_0xfa18('0x11')](_0xfa18('0x22'),_0x5c56f9);logger['debug'](_0xfa18('0x22'),_0x5c56f9,JSON['stringify'](_0x2222ab));_0x40ebd6(_0x2222ab);})[_0xfa18('0x21')](function(_0x418af1){logger[_0xfa18('0x15')](_0xfa18('0x22'),_0x418af1['message'],_0x5c56f9);_0x16082f(_0x220fbd['error'](0x1f4,_0x418af1['message']));});});};