Built motion from commit (unavailable).|2.5.31
[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 _0x5316=['then','info','Pause,\x20%s,\x20%s','request\x20sent','debug','Pause,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','ShowPause','Pause','find','options','raw','where','attributes','include','map','model','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','request'];(function(_0x3c4f40,_0x302e0b){var _0x12032f=function(_0x159d92){while(--_0x159d92){_0x3c4f40['push'](_0x3c4f40['shift']());}};_0x12032f(++_0x302e0b);}(_0x5316,0x115));var _0x6531=function(_0x3f6565,_0x12a8bb){_0x3f6565=_0x3f6565-0x0;var _0x4abd23=_0x5316[_0x3f6565];return _0x4abd23;};'use strict';var _=require(_0x6531('0x0'));var util=require('util');var moment=require(_0x6531('0x1'));var BPromise=require('bluebird');var rs=require(_0x6531('0x2'));var fs=require('fs');var Redis=require(_0x6531('0x3'));var db=require(_0x6531('0x4'))['db'];var utils=require(_0x6531('0x5'));var logger=require(_0x6531('0x6'))(_0x6531('0x7'));var config=require(_0x6531('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x6531('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2c2753,_0x5db303,_0xf80281){return new BPromise(function(_0x305b42,_0x4c4c65){return client[_0x6531('0xa')](_0x2c2753,_0xf80281)[_0x6531('0xb')](function(_0x3d3b35){logger[_0x6531('0xc')](_0x6531('0xd'),_0x5db303,_0x6531('0xe'));logger[_0x6531('0xf')](_0x6531('0x10'),_0x5db303,_0x6531('0xe'),JSON[_0x6531('0x11')](_0x3d3b35));if(_0x3d3b35[_0x6531('0x12')]){if(_0x3d3b35[_0x6531('0x12')][_0x6531('0x13')]===0x1f4){logger['error']('Pause,\x20%s,\x20%s',_0x5db303,_0x3d3b35[_0x6531('0x12')][_0x6531('0x14')]);return _0x4c4c65(_0x3d3b35['error']['message']);}logger['error'](_0x6531('0xd'),_0x5db303,_0x3d3b35['error'][_0x6531('0x14')]);return _0x305b42(_0x3d3b35['error'][_0x6531('0x14')]);}else{logger['info'](_0x6531('0xd'),_0x5db303,'request\x20sent');_0x305b42(_0x3d3b35['result']['message']);}})[_0x6531('0x15')](function(_0x15a3ea){logger['error'](_0x6531('0xd'),_0x5db303,_0x15a3ea);_0x4c4c65(_0x15a3ea);});});}exports[_0x6531('0x16')]=function(_0x4e5736){var _0x410c9e=this;return new Promise(function(_0x26cd1d,_0x111c0f){return db[_0x6531('0x17')][_0x6531('0x18')]({'raw':_0x4e5736[_0x6531('0x19')]?_0x4e5736[_0x6531('0x19')][_0x6531('0x1a')]===undefined?!![]:![]:!![],'where':_0x4e5736[_0x6531('0x19')]?_0x4e5736['options'][_0x6531('0x1b')]||null:null,'attributes':_0x4e5736[_0x6531('0x19')]?_0x4e5736[_0x6531('0x19')][_0x6531('0x1c')]||null:null,'include':_0x4e5736['options']?_0x4e5736['options'][_0x6531('0x1d')]?_[_0x6531('0x1e')](_0x4e5736[_0x6531('0x19')][_0x6531('0x1d')],function(_0x4bf7d0){return{'model':db[_0x4bf7d0[_0x6531('0x1f')]],'as':_0x4bf7d0['as'],'attributes':_0x4bf7d0['attributes'],'include':_0x4bf7d0[_0x6531('0x1d')]?_[_0x6531('0x1e')](_0x4bf7d0['include'],function(_0x4db74e){return{'model':db[_0x4db74e['model']],'as':_0x4db74e['as'],'attributes':_0x4db74e[_0x6531('0x1c')],'include':_0x4db74e[_0x6531('0x1d')]?_['map'](_0x4db74e[_0x6531('0x1d')],function(_0x348aef){return{'model':db[_0x348aef[_0x6531('0x1f')]],'as':_0x348aef['as'],'attributes':_0x348aef[_0x6531('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x6531('0xb')](function(_0x53a1d2){logger[_0x6531('0xc')](_0x6531('0x16'),_0x4e5736);logger[_0x6531('0xf')](_0x6531('0x16'),_0x4e5736,JSON[_0x6531('0x11')](_0x53a1d2));_0x26cd1d(_0x53a1d2);})['catch'](function(_0x3fad18){logger['error'](_0x6531('0x16'),_0x3fad18[_0x6531('0x14')],_0x4e5736);_0x111c0f(_0x410c9e['error'](0x1f4,_0x3fad18[_0x6531('0x14')]));});});};