Built motion from commit (unavailable).|2.4.4
[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 _0x6f5c=['include','model','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','then','info','request\x20sent','debug','Pause,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','Pause,\x20%s,\x20%s','ShowPause','options','where','attributes','map'];(function(_0x2d80af,_0xfdfd5b){var _0x4917c6=function(_0x3f9581){while(--_0x3f9581){_0x2d80af['push'](_0x2d80af['shift']());}};_0x4917c6(++_0xfdfd5b);}(_0x6f5c,0x7a));var _0xc6f5=function(_0x52ca3c,_0x18707c){_0x52ca3c=_0x52ca3c-0x0;var _0x12dbd8=_0x6f5c[_0x52ca3c];return _0x12dbd8;};'use strict';var _=require(_0xc6f5('0x0'));var util=require(_0xc6f5('0x1'));var moment=require(_0xc6f5('0x2'));var BPromise=require(_0xc6f5('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xc6f5('0x4'))['db'];var utils=require(_0xc6f5('0x5'));var logger=require(_0xc6f5('0x6'))(_0xc6f5('0x7'));var config=require(_0xc6f5('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xc6f5('0x9')][_0xc6f5('0xa')]({'port':0x232a});function respondWithRpcPromise(_0xaefa11,_0x100b5c,_0x233e70){return new BPromise(function(_0x7c2f3d,_0x1fd53b){return client[_0xc6f5('0xb')](_0xaefa11,_0x233e70)[_0xc6f5('0xc')](function(_0x125d76){logger[_0xc6f5('0xd')]('Pause,\x20%s,\x20%s',_0x100b5c,_0xc6f5('0xe'));logger[_0xc6f5('0xf')](_0xc6f5('0x10'),_0x100b5c,_0xc6f5('0xe'),JSON[_0xc6f5('0x11')](_0x125d76));if(_0x125d76[_0xc6f5('0x12')]){if(_0x125d76['error'][_0xc6f5('0x13')]===0x1f4){logger[_0xc6f5('0x12')]('Pause,\x20%s,\x20%s',_0x100b5c,_0x125d76[_0xc6f5('0x12')][_0xc6f5('0x14')]);return _0x1fd53b(_0x125d76[_0xc6f5('0x12')]['message']);}logger[_0xc6f5('0x12')]('Pause,\x20%s,\x20%s',_0x100b5c,_0x125d76['error'][_0xc6f5('0x14')]);return _0x7c2f3d(_0x125d76['error'][_0xc6f5('0x14')]);}else{logger[_0xc6f5('0xd')]('Pause,\x20%s,\x20%s',_0x100b5c,'request\x20sent');_0x7c2f3d(_0x125d76['result'][_0xc6f5('0x14')]);}})[_0xc6f5('0x15')](function(_0x5f5d41){logger[_0xc6f5('0x12')](_0xc6f5('0x16'),_0x100b5c,_0x5f5d41);_0x1fd53b(_0x5f5d41);});});}exports[_0xc6f5('0x17')]=function(_0x54e995){var _0x201764=this;return new Promise(function(_0x196569,_0x10b790){return db['Pause']['find']({'raw':_0x54e995['options']?_0x54e995[_0xc6f5('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x54e995[_0xc6f5('0x18')]?_0x54e995[_0xc6f5('0x18')][_0xc6f5('0x19')]||null:null,'attributes':_0x54e995['options']?_0x54e995['options'][_0xc6f5('0x1a')]||null:null,'include':_0x54e995[_0xc6f5('0x18')]?_0x54e995[_0xc6f5('0x18')]['include']?_[_0xc6f5('0x1b')](_0x54e995[_0xc6f5('0x18')][_0xc6f5('0x1c')],function(_0x58bbf7){return{'model':db[_0x58bbf7[_0xc6f5('0x1d')]],'as':_0x58bbf7['as'],'attributes':_0x58bbf7[_0xc6f5('0x1a')],'include':_0x58bbf7[_0xc6f5('0x1c')]?_[_0xc6f5('0x1b')](_0x58bbf7[_0xc6f5('0x1c')],function(_0x3d1495){return{'model':db[_0x3d1495['model']],'as':_0x3d1495['as'],'attributes':_0x3d1495['attributes'],'include':_0x3d1495['include']?_['map'](_0x3d1495['include'],function(_0x1cfb4d){return{'model':db[_0x1cfb4d[_0xc6f5('0x1d')]],'as':_0x1cfb4d['as'],'attributes':_0x1cfb4d['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x51307c){logger['info']('ShowPause',_0x54e995);logger[_0xc6f5('0xf')](_0xc6f5('0x17'),_0x54e995,JSON[_0xc6f5('0x11')](_0x51307c));_0x196569(_0x51307c);})[_0xc6f5('0x15')](function(_0x1d138a){logger[_0xc6f5('0x12')](_0xc6f5('0x17'),_0x1d138a[_0xc6f5('0x14')],_0x54e995);_0x10b790(_0x201764['error'](0x1f4,_0x1d138a[_0xc6f5('0x14')]));});});};