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 _0x8146=['request','Pause,\x20%s,\x20%s','request\x20sent','debug','error','code','message','info','catch','Pause','find','raw','options','where','attributes','include','map','model','ShowPause','stringify','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http'];(function(_0x538c5f,_0x172ae7){var _0x183649=function(_0x57ac0b){while(--_0x57ac0b){_0x538c5f['push'](_0x538c5f['shift']());}};_0x183649(++_0x172ae7);}(_0x8146,0x194));var _0x6814=function(_0x3cbcfa,_0x3af16b){_0x3cbcfa=_0x3cbcfa-0x0;var _0x546d83=_0x8146[_0x3cbcfa];return _0x546d83;};'use strict';var _=require(_0x6814('0x0'));var util=require('util');var moment=require(_0x6814('0x1'));var BPromise=require(_0x6814('0x2'));var rs=require(_0x6814('0x3'));var fs=require('fs');var Redis=require(_0x6814('0x4'));var db=require(_0x6814('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x6814('0x6'))(_0x6814('0x7'));var config=require(_0x6814('0x8'));var jayson=require(_0x6814('0x9'));var client=jayson[_0x6814('0xa')][_0x6814('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x1a5ea7,_0x340b35,_0x4bee8c){return new BPromise(function(_0x1a058f,_0x2692d1){return client[_0x6814('0xc')](_0x1a5ea7,_0x4bee8c)['then'](function(_0x3a7f04){logger['info'](_0x6814('0xd'),_0x340b35,_0x6814('0xe'));logger[_0x6814('0xf')]('Pause,\x20%s,\x20%s,\x20%s',_0x340b35,_0x6814('0xe'),JSON['stringify'](_0x3a7f04));if(_0x3a7f04[_0x6814('0x10')]){if(_0x3a7f04[_0x6814('0x10')][_0x6814('0x11')]===0x1f4){logger[_0x6814('0x10')](_0x6814('0xd'),_0x340b35,_0x3a7f04[_0x6814('0x10')][_0x6814('0x12')]);return _0x2692d1(_0x3a7f04[_0x6814('0x10')][_0x6814('0x12')]);}logger['error']('Pause,\x20%s,\x20%s',_0x340b35,_0x3a7f04[_0x6814('0x10')][_0x6814('0x12')]);return _0x1a058f(_0x3a7f04[_0x6814('0x10')][_0x6814('0x12')]);}else{logger[_0x6814('0x13')]('Pause,\x20%s,\x20%s',_0x340b35,_0x6814('0xe'));_0x1a058f(_0x3a7f04['result']['message']);}})[_0x6814('0x14')](function(_0x29c339){logger['error'](_0x6814('0xd'),_0x340b35,_0x29c339);_0x2692d1(_0x29c339);});});}exports['ShowPause']=function(_0x33f82c){var _0x5b8999=this;return new Promise(function(_0x2da349,_0x45e0fa){return db[_0x6814('0x15')][_0x6814('0x16')]({'raw':_0x33f82c['options']?_0x33f82c['options'][_0x6814('0x17')]===undefined?!![]:![]:!![],'where':_0x33f82c[_0x6814('0x18')]?_0x33f82c[_0x6814('0x18')][_0x6814('0x19')]||null:null,'attributes':_0x33f82c[_0x6814('0x18')]?_0x33f82c[_0x6814('0x18')][_0x6814('0x1a')]||null:null,'include':_0x33f82c[_0x6814('0x18')]?_0x33f82c['options'][_0x6814('0x1b')]?_[_0x6814('0x1c')](_0x33f82c[_0x6814('0x18')][_0x6814('0x1b')],function(_0x2a14bb){return{'model':db[_0x2a14bb['model']],'as':_0x2a14bb['as'],'attributes':_0x2a14bb['attributes'],'include':_0x2a14bb[_0x6814('0x1b')]?_[_0x6814('0x1c')](_0x2a14bb[_0x6814('0x1b')],function(_0x5bb14f){return{'model':db[_0x5bb14f[_0x6814('0x1d')]],'as':_0x5bb14f['as'],'attributes':_0x5bb14f[_0x6814('0x1a')],'include':_0x5bb14f[_0x6814('0x1b')]?_[_0x6814('0x1c')](_0x5bb14f[_0x6814('0x1b')],function(_0xf7a18c){return{'model':db[_0xf7a18c[_0x6814('0x1d')]],'as':_0xf7a18c['as'],'attributes':_0xf7a18c[_0x6814('0x1a')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x709357){logger[_0x6814('0x13')](_0x6814('0x1e'),_0x33f82c);logger[_0x6814('0xf')](_0x6814('0x1e'),_0x33f82c,JSON[_0x6814('0x1f')](_0x709357));_0x2da349(_0x709357);})[_0x6814('0x14')](function(_0x1f6156){logger['error'](_0x6814('0x1e'),_0x1f6156[_0x6814('0x12')],_0x33f82c);_0x45e0fa(_0x5b8999[_0x6814('0x10')](0x1f4,_0x1f6156[_0x6814('0x12')]));});});};