fcbd46471ef29cffffe05b5420a1e14f567e901b
[motion2.git] / server / api / pause / pause.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 _0x3487=['Pause,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','ShowPause','Pause','find','options','where','attributes','include','model','map','then','lodash','util','moment','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','request','Pause,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x5a45eb,_0x1b2b99){var _0x39d9bc=function(_0x27c74f){while(--_0x27c74f){_0x5a45eb['push'](_0x5a45eb['shift']());}};_0x39d9bc(++_0x1b2b99);}(_0x3487,0xd8));var _0x7348=function(_0x544099,_0x372b30){_0x544099=_0x544099-0x0;var _0x20ab09=_0x3487[_0x544099];return _0x20ab09;};'use strict';var _=require(_0x7348('0x0'));var util=require(_0x7348('0x1'));var moment=require(_0x7348('0x2'));var BPromise=require('bluebird');var rs=require(_0x7348('0x3'));var fs=require('fs');var Redis=require(_0x7348('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x7348('0x5'));var logger=require(_0x7348('0x6'))('rpc');var config=require(_0x7348('0x7'));var jayson=require(_0x7348('0x8'));var client=jayson[_0x7348('0x9')][_0x7348('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x591fbe,_0x323568,_0x488767){return new BPromise(function(_0x4ddafb,_0x40e2d1){return client[_0x7348('0xb')](_0x591fbe,_0x488767)['then'](function(_0x5d1819){logger['info'](_0x7348('0xc'),_0x323568,_0x7348('0xd'));logger[_0x7348('0xe')](_0x7348('0xf'),_0x323568,'request\x20sent',JSON[_0x7348('0x10')](_0x5d1819));if(_0x5d1819[_0x7348('0x11')]){if(_0x5d1819[_0x7348('0x11')][_0x7348('0x12')]===0x1f4){logger[_0x7348('0x11')]('Pause,\x20%s,\x20%s',_0x323568,_0x5d1819[_0x7348('0x11')][_0x7348('0x13')]);return _0x40e2d1(_0x5d1819['error'][_0x7348('0x13')]);}logger[_0x7348('0x11')]('Pause,\x20%s,\x20%s',_0x323568,_0x5d1819[_0x7348('0x11')][_0x7348('0x13')]);return _0x4ddafb(_0x5d1819[_0x7348('0x11')][_0x7348('0x13')]);}else{logger[_0x7348('0x14')]('Pause,\x20%s,\x20%s',_0x323568,_0x7348('0xd'));_0x4ddafb(_0x5d1819[_0x7348('0x15')]['message']);}})[_0x7348('0x16')](function(_0x3f7084){logger[_0x7348('0x11')]('Pause,\x20%s,\x20%s',_0x323568,_0x3f7084);_0x40e2d1(_0x3f7084);});});}exports[_0x7348('0x17')]=function(_0x3f14cb){var _0x2becc7=this;return new Promise(function(_0x14122c,_0xd45a03){return db[_0x7348('0x18')][_0x7348('0x19')]({'raw':_0x3f14cb[_0x7348('0x1a')]?_0x3f14cb[_0x7348('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x3f14cb[_0x7348('0x1a')]?_0x3f14cb['options'][_0x7348('0x1b')]||null:null,'attributes':_0x3f14cb[_0x7348('0x1a')]?_0x3f14cb['options'][_0x7348('0x1c')]||null:null,'include':_0x3f14cb[_0x7348('0x1a')]?_0x3f14cb[_0x7348('0x1a')][_0x7348('0x1d')]?_['map'](_0x3f14cb[_0x7348('0x1a')][_0x7348('0x1d')],function(_0x540b7e){return{'model':db[_0x540b7e[_0x7348('0x1e')]],'as':_0x540b7e['as'],'attributes':_0x540b7e[_0x7348('0x1c')],'include':_0x540b7e['include']?_['map'](_0x540b7e[_0x7348('0x1d')],function(_0x11eae8){return{'model':db[_0x11eae8[_0x7348('0x1e')]],'as':_0x11eae8['as'],'attributes':_0x11eae8[_0x7348('0x1c')],'include':_0x11eae8[_0x7348('0x1d')]?_[_0x7348('0x1f')](_0x11eae8[_0x7348('0x1d')],function(_0x5857f2){return{'model':db[_0x5857f2[_0x7348('0x1e')]],'as':_0x5857f2['as'],'attributes':_0x5857f2[_0x7348('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x7348('0x20')](function(_0xd965d6){logger[_0x7348('0x14')](_0x7348('0x17'),_0x3f14cb);logger['debug'](_0x7348('0x17'),_0x3f14cb,JSON[_0x7348('0x10')](_0xd965d6));_0x14122c(_0xd965d6);})['catch'](function(_0xc41bea){logger[_0x7348('0x11')](_0x7348('0x17'),_0xc41bea[_0x7348('0x13')],_0x3f14cb);_0xd45a03(_0x2becc7[_0x7348('0x11')](0x1f4,_0xc41bea[_0x7348('0x13')]));});});};