345a994e9644ec79ccf0e9c6032a99b1b1f0fa15
[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 _0xb547=['then','debug','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','jayson/promise','request','info','Pause,\x20%s,\x20%s','request\x20sent','Pause,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','ShowPause','Pause','options','raw','where','attributes','include','model','map'];(function(_0x56fbb6,_0x570f05){var _0x4e9a77=function(_0x320be4){while(--_0x320be4){_0x56fbb6['push'](_0x56fbb6['shift']());}};_0x4e9a77(++_0x570f05);}(_0xb547,0x143));var _0x7b54=function(_0x1ea6eb,_0x33d3d4){_0x1ea6eb=_0x1ea6eb-0x0;var _0x127200=_0xb547[_0x1ea6eb];return _0x127200;};'use strict';var _=require(_0x7b54('0x0'));var util=require(_0x7b54('0x1'));var moment=require(_0x7b54('0x2'));var BPromise=require(_0x7b54('0x3'));var rs=require(_0x7b54('0x4'));var fs=require('fs');var Redis=require(_0x7b54('0x5'));var db=require(_0x7b54('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x7b54('0x7'))(_0x7b54('0x8'));var config=require('../../config/environment');var jayson=require(_0x7b54('0x9'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x3cde77,_0x473644,_0x2f71ca){return new BPromise(function(_0x13e3bf,_0xc8e7f){return client[_0x7b54('0xa')](_0x3cde77,_0x2f71ca)['then'](function(_0x44d718){logger[_0x7b54('0xb')](_0x7b54('0xc'),_0x473644,_0x7b54('0xd'));logger['debug'](_0x7b54('0xe'),_0x473644,_0x7b54('0xd'),JSON[_0x7b54('0xf')](_0x44d718));if(_0x44d718['error']){if(_0x44d718[_0x7b54('0x10')][_0x7b54('0x11')]===0x1f4){logger[_0x7b54('0x10')](_0x7b54('0xc'),_0x473644,_0x44d718[_0x7b54('0x10')]['message']);return _0xc8e7f(_0x44d718[_0x7b54('0x10')][_0x7b54('0x12')]);}logger['error'](_0x7b54('0xc'),_0x473644,_0x44d718[_0x7b54('0x10')]['message']);return _0x13e3bf(_0x44d718[_0x7b54('0x10')]['message']);}else{logger[_0x7b54('0xb')](_0x7b54('0xc'),_0x473644,'request\x20sent');_0x13e3bf(_0x44d718[_0x7b54('0x13')]['message']);}})['catch'](function(_0xc9f1c0){logger[_0x7b54('0x10')](_0x7b54('0xc'),_0x473644,_0xc9f1c0);_0xc8e7f(_0xc9f1c0);});});}exports[_0x7b54('0x14')]=function(_0x4f0a7f){var _0x53990c=this;return new Promise(function(_0x182431,_0x4b9eb3){return db[_0x7b54('0x15')]['find']({'raw':_0x4f0a7f['options']?_0x4f0a7f[_0x7b54('0x16')][_0x7b54('0x17')]===undefined?!![]:![]:!![],'where':_0x4f0a7f[_0x7b54('0x16')]?_0x4f0a7f[_0x7b54('0x16')][_0x7b54('0x18')]||null:null,'attributes':_0x4f0a7f['options']?_0x4f0a7f[_0x7b54('0x16')][_0x7b54('0x19')]||null:null,'include':_0x4f0a7f[_0x7b54('0x16')]?_0x4f0a7f['options'][_0x7b54('0x1a')]?_['map'](_0x4f0a7f[_0x7b54('0x16')][_0x7b54('0x1a')],function(_0x2ebcd6){return{'model':db[_0x2ebcd6[_0x7b54('0x1b')]],'as':_0x2ebcd6['as'],'attributes':_0x2ebcd6['attributes'],'include':_0x2ebcd6[_0x7b54('0x1a')]?_[_0x7b54('0x1c')](_0x2ebcd6['include'],function(_0x4cd243){return{'model':db[_0x4cd243['model']],'as':_0x4cd243['as'],'attributes':_0x4cd243['attributes'],'include':_0x4cd243[_0x7b54('0x1a')]?_['map'](_0x4cd243[_0x7b54('0x1a')],function(_0x487bab){return{'model':db[_0x487bab[_0x7b54('0x1b')]],'as':_0x487bab['as'],'attributes':_0x487bab[_0x7b54('0x19')]};}):[]};}):[]};}):[]:[]})[_0x7b54('0x1d')](function(_0xc89b4d){logger[_0x7b54('0xb')](_0x7b54('0x14'),_0x4f0a7f);logger[_0x7b54('0x1e')](_0x7b54('0x14'),_0x4f0a7f,JSON['stringify'](_0xc89b4d));_0x182431(_0xc89b4d);})[_0x7b54('0x1f')](function(_0x3ea38b){logger[_0x7b54('0x10')](_0x7b54('0x14'),_0x3ea38b[_0x7b54('0x12')],_0x4f0a7f);_0x4b9eb3(_0x53990c[_0x7b54('0x10')](0x1f4,_0x3ea38b['message']));});});};