Built motion from commit 67e5df37.|2.0.66
[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 _0xa9e0=['rpc','../../config/environment','jayson/promise','client','socket.io-emitter','localhost','./chatQueue.socket','request','then','info','ChatQueue,\x20%s,\x20%s','stringify','error','code','message','request\x20sent','result','catch','GetChatQueue','ChatQueue','findAll','options','raw','where','limit','map','include','model','attributes','debug','ShowChatQueue','find','lodash','util','moment','../../mysqldb','../../config/logger'];(function(_0x329e14,_0x4422fe){var _0x278570=function(_0x15d88d){while(--_0x15d88d){_0x329e14['push'](_0x329e14['shift']());}};_0x278570(++_0x4422fe);}(_0xa9e0,0x123));var _0x0a9e=function(_0x2bf141,_0x31eac7){_0x2bf141=_0x2bf141-0x0;var _0x48277b=_0xa9e0[_0x2bf141];return _0x48277b;};'use strict';var _=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var moment=require(_0x0a9e('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var db=require(_0x0a9e('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x0a9e('0x4'))(_0x0a9e('0x5'));var config=require(_0x0a9e('0x6'));var jayson=require(_0x0a9e('0x7'));var client=jayson[_0x0a9e('0x8')]['http']({'port':0x232a});var socket=require(_0x0a9e('0x9'))({'host':_0x0a9e('0xa'),'port':0x18eb});require(_0x0a9e('0xb'))['register'](socket);function respondWithRpcPromise(_0x503809,_0xe42b77,_0x56465b){return new BPromise(function(_0x52cace,_0x39753a){return client[_0x0a9e('0xc')](_0x503809,_0x56465b)[_0x0a9e('0xd')](function(_0x3ab53f){logger[_0x0a9e('0xe')](_0x0a9e('0xf'),_0xe42b77,'request\x20sent');logger['debug']('ChatQueue,\x20%s,\x20%s,\x20%s',_0xe42b77,'request\x20sent',JSON[_0x0a9e('0x10')](_0x3ab53f));if(_0x3ab53f[_0x0a9e('0x11')]){if(_0x3ab53f[_0x0a9e('0x11')][_0x0a9e('0x12')]===0x1f4){logger[_0x0a9e('0x11')](_0x0a9e('0xf'),_0xe42b77,_0x3ab53f['error'][_0x0a9e('0x13')]);return _0x39753a(_0x3ab53f[_0x0a9e('0x11')][_0x0a9e('0x13')]);}logger[_0x0a9e('0x11')](_0x0a9e('0xf'),_0xe42b77,_0x3ab53f[_0x0a9e('0x11')]['message']);return _0x52cace(_0x3ab53f[_0x0a9e('0x11')]['message']);}else{logger[_0x0a9e('0xe')]('ChatQueue,\x20%s,\x20%s',_0xe42b77,_0x0a9e('0x14'));_0x52cace(_0x3ab53f[_0x0a9e('0x15')]['message']);}})[_0x0a9e('0x16')](function(_0x5a0a06){logger[_0x0a9e('0x11')](_0x0a9e('0xf'),_0xe42b77,_0x5a0a06);_0x39753a(_0x5a0a06);});});}exports[_0x0a9e('0x17')]=function(_0x205fd6){var _0x31b1ca=this;return new Promise(function(_0x2eb11f,_0x530eb7){return db[_0x0a9e('0x18')][_0x0a9e('0x19')]({'raw':_0x205fd6[_0x0a9e('0x1a')]?_0x205fd6[_0x0a9e('0x1a')][_0x0a9e('0x1b')]===undefined?!![]:![]:!![],'where':_0x205fd6['options']?_0x205fd6[_0x0a9e('0x1a')][_0x0a9e('0x1c')]||null:null,'attributes':_0x205fd6['options']?_0x205fd6[_0x0a9e('0x1a')]['attributes']||null:null,'limit':_0x205fd6['options']?_0x205fd6[_0x0a9e('0x1a')][_0x0a9e('0x1d')]||null:null,'include':_0x205fd6[_0x0a9e('0x1a')]?_0x205fd6[_0x0a9e('0x1a')]['include']?_[_0x0a9e('0x1e')](_0x205fd6[_0x0a9e('0x1a')][_0x0a9e('0x1f')],function(_0x4d00e6){return{'model':db[_0x4d00e6[_0x0a9e('0x20')]],'as':_0x4d00e6['as'],'attributes':_0x4d00e6[_0x0a9e('0x21')],'include':_0x4d00e6[_0x0a9e('0x1f')]?_['map'](_0x4d00e6['include'],function(_0x197ec0){return{'model':db[_0x197ec0[_0x0a9e('0x20')]],'as':_0x197ec0['as'],'attributes':_0x197ec0[_0x0a9e('0x21')],'include':_0x197ec0[_0x0a9e('0x1f')]?_['map'](_0x197ec0[_0x0a9e('0x1f')],function(_0x479bc4){return{'model':db[_0x479bc4[_0x0a9e('0x20')]],'as':_0x479bc4['as'],'attributes':_0x479bc4['attributes']};}):[]};}):[]};}):[]:[]})[_0x0a9e('0xd')](function(_0x34dc65){logger[_0x0a9e('0xe')](_0x0a9e('0x17'),_0x205fd6);logger[_0x0a9e('0x22')](_0x0a9e('0x17'),_0x205fd6,JSON[_0x0a9e('0x10')](_0x34dc65));_0x2eb11f(_0x34dc65);})[_0x0a9e('0x16')](function(_0x5a101a){logger[_0x0a9e('0x11')](_0x0a9e('0x17'),_0x5a101a[_0x0a9e('0x13')],_0x205fd6);_0x530eb7(_0x31b1ca[_0x0a9e('0x11')](0x1f4,_0x5a101a['message']));});});};exports[_0x0a9e('0x23')]=function(_0x40e7a3){var _0x1843b2=this;return new Promise(function(_0x824a4f,_0x58b06f){return db[_0x0a9e('0x18')][_0x0a9e('0x24')]({'raw':_0x40e7a3[_0x0a9e('0x1a')]?_0x40e7a3[_0x0a9e('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x40e7a3[_0x0a9e('0x1a')]?_0x40e7a3['options'][_0x0a9e('0x1c')]||null:null,'attributes':_0x40e7a3[_0x0a9e('0x1a')]?_0x40e7a3[_0x0a9e('0x1a')][_0x0a9e('0x21')]||null:null,'include':_0x40e7a3[_0x0a9e('0x1a')]?_0x40e7a3['options'][_0x0a9e('0x1f')]?_[_0x0a9e('0x1e')](_0x40e7a3[_0x0a9e('0x1a')][_0x0a9e('0x1f')],function(_0x2b45ea){return{'model':db[_0x2b45ea[_0x0a9e('0x20')]],'as':_0x2b45ea['as'],'attributes':_0x2b45ea[_0x0a9e('0x21')],'include':_0x2b45ea[_0x0a9e('0x1f')]?_['map'](_0x2b45ea[_0x0a9e('0x1f')],function(_0x5e7238){return{'model':db[_0x5e7238[_0x0a9e('0x20')]],'as':_0x5e7238['as'],'attributes':_0x5e7238[_0x0a9e('0x21')],'include':_0x5e7238[_0x0a9e('0x1f')]?_[_0x0a9e('0x1e')](_0x5e7238['include'],function(_0x191e91){return{'model':db[_0x191e91[_0x0a9e('0x20')]],'as':_0x191e91['as'],'attributes':_0x191e91[_0x0a9e('0x21')]};}):[]};}):[]};}):[]:[]})[_0x0a9e('0xd')](function(_0x4853b1){logger['info'](_0x0a9e('0x23'),_0x40e7a3);logger['debug'](_0x0a9e('0x23'),_0x40e7a3,JSON[_0x0a9e('0x10')](_0x4853b1));_0x824a4f(_0x4853b1);})[_0x0a9e('0x16')](function(_0x1ef87a){logger['error'](_0x0a9e('0x23'),_0x1ef87a[_0x0a9e('0x13')],_0x40e7a3);_0x58b06f(_0x1843b2[_0x0a9e('0x11')](0x1f4,_0x1ef87a['message']));});});};