Built motion from commit da617fac.|2.6.6
[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 _0x3276=['model','map','ShowChatQueue','find','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client','http','redis','localhost','socket.io-emitter','register','request','then','ChatQueue,\x20%s,\x20%s','request\x20sent','debug','ChatQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','GetChatQueue','findAll','options','raw','where','attributes','limit','include'];(function(_0x318248,_0x3d2dbc){var _0x3eb033=function(_0xb4dce){while(--_0xb4dce){_0x318248['push'](_0x318248['shift']());}};_0x3eb033(++_0x3d2dbc);}(_0x3276,0xc7));var _0x6327=function(_0x4c6e82,_0x1cfb6f){_0x4c6e82=_0x4c6e82-0x0;var _0x30785b=_0x3276[_0x4c6e82];return _0x30785b;};'use strict';var _=require(_0x6327('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x6327('0x1'));var rs=require(_0x6327('0x2'));var fs=require('fs');var Redis=require(_0x6327('0x3'));var db=require(_0x6327('0x4'))['db'];var utils=require(_0x6327('0x5'));var logger=require(_0x6327('0x6'))(_0x6327('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x6327('0x8')][_0x6327('0x9')]({'port':0x232a});config[_0x6327('0xa')]=_['defaults'](config[_0x6327('0xa')],{'host':_0x6327('0xb'),'port':0x18eb});var socket=require(_0x6327('0xc'))(new Redis(config[_0x6327('0xa')]));require('./chatQueue.socket')[_0x6327('0xd')](socket);function respondWithRpcPromise(_0x1687c4,_0x4e8256,_0x443b6f){return new BPromise(function(_0x289415,_0x572a9f){return client[_0x6327('0xe')](_0x1687c4,_0x443b6f)[_0x6327('0xf')](function(_0x95c9be){logger['info'](_0x6327('0x10'),_0x4e8256,_0x6327('0x11'));logger[_0x6327('0x12')](_0x6327('0x13'),_0x4e8256,_0x6327('0x11'),JSON[_0x6327('0x14')](_0x95c9be));if(_0x95c9be[_0x6327('0x15')]){if(_0x95c9be[_0x6327('0x15')][_0x6327('0x16')]===0x1f4){logger[_0x6327('0x15')]('ChatQueue,\x20%s,\x20%s',_0x4e8256,_0x95c9be[_0x6327('0x15')]['message']);return _0x572a9f(_0x95c9be[_0x6327('0x15')][_0x6327('0x17')]);}logger[_0x6327('0x15')]('ChatQueue,\x20%s,\x20%s',_0x4e8256,_0x95c9be[_0x6327('0x15')][_0x6327('0x17')]);return _0x289415(_0x95c9be[_0x6327('0x15')][_0x6327('0x17')]);}else{logger[_0x6327('0x18')](_0x6327('0x10'),_0x4e8256,_0x6327('0x11'));_0x289415(_0x95c9be[_0x6327('0x19')][_0x6327('0x17')]);}})[_0x6327('0x1a')](function(_0x7168f7){logger[_0x6327('0x15')]('ChatQueue,\x20%s,\x20%s',_0x4e8256,_0x7168f7);_0x572a9f(_0x7168f7);});});}exports[_0x6327('0x1b')]=function(_0x12c33f){var _0x29b061=this;return new Promise(function(_0x341916,_0x4cbc80){return db['ChatQueue'][_0x6327('0x1c')]({'raw':_0x12c33f[_0x6327('0x1d')]?_0x12c33f[_0x6327('0x1d')][_0x6327('0x1e')]===undefined?!![]:![]:!![],'where':_0x12c33f[_0x6327('0x1d')]?_0x12c33f[_0x6327('0x1d')][_0x6327('0x1f')]||null:null,'attributes':_0x12c33f[_0x6327('0x1d')]?_0x12c33f[_0x6327('0x1d')][_0x6327('0x20')]||null:null,'limit':_0x12c33f[_0x6327('0x1d')]?_0x12c33f[_0x6327('0x1d')][_0x6327('0x21')]||null:null,'include':_0x12c33f[_0x6327('0x1d')]?_0x12c33f[_0x6327('0x1d')][_0x6327('0x22')]?_['map'](_0x12c33f['options'][_0x6327('0x22')],function(_0x499321){return{'model':db[_0x499321[_0x6327('0x23')]],'as':_0x499321['as'],'attributes':_0x499321['attributes'],'include':_0x499321[_0x6327('0x22')]?_['map'](_0x499321[_0x6327('0x22')],function(_0x1eae65){return{'model':db[_0x1eae65['model']],'as':_0x1eae65['as'],'attributes':_0x1eae65[_0x6327('0x20')],'include':_0x1eae65[_0x6327('0x22')]?_[_0x6327('0x24')](_0x1eae65[_0x6327('0x22')],function(_0x894157){return{'model':db[_0x894157[_0x6327('0x23')]],'as':_0x894157['as'],'attributes':_0x894157[_0x6327('0x20')]};}):[]};}):[]};}):[]:[]})[_0x6327('0xf')](function(_0x58b590){logger[_0x6327('0x18')](_0x6327('0x1b'),_0x12c33f);logger['debug'](_0x6327('0x1b'),_0x12c33f,JSON[_0x6327('0x14')](_0x58b590));_0x341916(_0x58b590);})['catch'](function(_0x43bcd0){logger[_0x6327('0x15')](_0x6327('0x1b'),_0x43bcd0['message'],_0x12c33f);_0x4cbc80(_0x29b061[_0x6327('0x15')](0x1f4,_0x43bcd0[_0x6327('0x17')]));});});};exports[_0x6327('0x25')]=function(_0x2c986a){var _0x523b52=this;return new Promise(function(_0xf7b0a3,_0x543d31){return db['ChatQueue'][_0x6327('0x26')]({'raw':_0x2c986a[_0x6327('0x1d')]?_0x2c986a[_0x6327('0x1d')][_0x6327('0x1e')]===undefined?!![]:![]:!![],'where':_0x2c986a['options']?_0x2c986a[_0x6327('0x1d')][_0x6327('0x1f')]||null:null,'attributes':_0x2c986a[_0x6327('0x1d')]?_0x2c986a[_0x6327('0x1d')]['attributes']||null:null,'include':_0x2c986a[_0x6327('0x1d')]?_0x2c986a[_0x6327('0x1d')][_0x6327('0x22')]?_['map'](_0x2c986a[_0x6327('0x1d')][_0x6327('0x22')],function(_0x456090){return{'model':db[_0x456090['model']],'as':_0x456090['as'],'attributes':_0x456090['attributes'],'include':_0x456090[_0x6327('0x22')]?_['map'](_0x456090[_0x6327('0x22')],function(_0x4b3d89){return{'model':db[_0x4b3d89[_0x6327('0x23')]],'as':_0x4b3d89['as'],'attributes':_0x4b3d89[_0x6327('0x20')],'include':_0x4b3d89[_0x6327('0x22')]?_[_0x6327('0x24')](_0x4b3d89[_0x6327('0x22')],function(_0x2b1982){return{'model':db[_0x2b1982['model']],'as':_0x2b1982['as'],'attributes':_0x2b1982[_0x6327('0x20')]};}):[]};}):[]};}):[]:[]})[_0x6327('0xf')](function(_0x154733){logger[_0x6327('0x18')]('ShowChatQueue',_0x2c986a);logger['debug'](_0x6327('0x25'),_0x2c986a,JSON[_0x6327('0x14')](_0x154733));_0xf7b0a3(_0x154733);})[_0x6327('0x1a')](function(_0x2b1b3f){logger[_0x6327('0x15')]('ShowChatQueue',_0x2b1b3f[_0x6327('0x17')],_0x2c986a);_0x543d31(_0x523b52[_0x6327('0x15')](0x1f4,_0x2b1b3f[_0x6327('0x17')]));});});};