ba3c5d187c44dcd086c794e58dfd5c86f4a5ffa7
[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 _0x670b=['code','message','info','result','catch','ShowPause','find','raw','options','where','attributes','include','model','map','lodash','util','randomstring','../../mysqldb','../../config/logger','rpc','jayson/promise','client','then','Pause,\x20%s,\x20%s','debug','Pause,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error'];(function(_0x42e1ec,_0x19aacc){var _0xe8c124=function(_0x21fe3f){while(--_0x21fe3f){_0x42e1ec['push'](_0x42e1ec['shift']());}};_0xe8c124(++_0x19aacc);}(_0x670b,0x130));var _0xb670=function(_0x3244ab,_0x3f7466){_0x3244ab=_0x3244ab-0x0;var _0x30f861=_0x670b[_0x3244ab];return _0x30f861;};'use strict';var _=require(_0xb670('0x0'));var util=require(_0xb670('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xb670('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xb670('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0xb670('0x4'))(_0xb670('0x5'));var config=require('../../config/environment');var jayson=require(_0xb670('0x6'));var client=jayson[_0xb670('0x7')]['http']({'port':0x232a});function respondWithRpcPromise(_0x3e8dd5,_0x31f0b2,_0x391690){return new BPromise(function(_0x2b68f6,_0x5aa138){return client['request'](_0x3e8dd5,_0x391690)[_0xb670('0x8')](function(_0x4bc45b){logger['info'](_0xb670('0x9'),_0x31f0b2,'request\x20sent');logger[_0xb670('0xa')](_0xb670('0xb'),_0x31f0b2,_0xb670('0xc'),JSON[_0xb670('0xd')](_0x4bc45b));if(_0x4bc45b[_0xb670('0xe')]){if(_0x4bc45b[_0xb670('0xe')][_0xb670('0xf')]===0x1f4){logger[_0xb670('0xe')](_0xb670('0x9'),_0x31f0b2,_0x4bc45b['error'][_0xb670('0x10')]);return _0x5aa138(_0x4bc45b[_0xb670('0xe')]['message']);}logger['error']('Pause,\x20%s,\x20%s',_0x31f0b2,_0x4bc45b[_0xb670('0xe')][_0xb670('0x10')]);return _0x2b68f6(_0x4bc45b[_0xb670('0xe')][_0xb670('0x10')]);}else{logger[_0xb670('0x11')](_0xb670('0x9'),_0x31f0b2,_0xb670('0xc'));_0x2b68f6(_0x4bc45b[_0xb670('0x12')]['message']);}})[_0xb670('0x13')](function(_0x242cc2){logger[_0xb670('0xe')](_0xb670('0x9'),_0x31f0b2,_0x242cc2);_0x5aa138(_0x242cc2);});});}exports[_0xb670('0x14')]=function(_0x2a1074){var _0x21a05f=this;return new Promise(function(_0x1cdba7,_0x46432c){return db['Pause'][_0xb670('0x15')]({'raw':_0x2a1074['options']?_0x2a1074['options'][_0xb670('0x16')]===undefined?!![]:![]:!![],'where':_0x2a1074[_0xb670('0x17')]?_0x2a1074[_0xb670('0x17')][_0xb670('0x18')]||null:null,'attributes':_0x2a1074[_0xb670('0x17')]?_0x2a1074[_0xb670('0x17')][_0xb670('0x19')]||null:null,'include':_0x2a1074[_0xb670('0x17')]?_0x2a1074['options'][_0xb670('0x1a')]?_['map'](_0x2a1074[_0xb670('0x17')]['include'],function(_0x36de9d){return{'model':db[_0x36de9d[_0xb670('0x1b')]],'as':_0x36de9d['as'],'attributes':_0x36de9d[_0xb670('0x19')],'include':_0x36de9d[_0xb670('0x1a')]?_[_0xb670('0x1c')](_0x36de9d['include'],function(_0x6b91e5){return{'model':db[_0x6b91e5[_0xb670('0x1b')]],'as':_0x6b91e5['as'],'attributes':_0x6b91e5[_0xb670('0x19')],'include':_0x6b91e5['include']?_['map'](_0x6b91e5[_0xb670('0x1a')],function(_0x1859ff){return{'model':db[_0x1859ff[_0xb670('0x1b')]],'as':_0x1859ff['as'],'attributes':_0x1859ff[_0xb670('0x19')]};}):[]};}):[]};}):[]:[]})[_0xb670('0x8')](function(_0x5e6cd5){logger[_0xb670('0x11')](_0xb670('0x14'),_0x2a1074);logger[_0xb670('0xa')](_0xb670('0x14'),_0x2a1074,JSON[_0xb670('0xd')](_0x5e6cd5));_0x1cdba7(_0x5e6cd5);})[_0xb670('0x13')](function(_0x209ffb){logger['error']('ShowPause',_0x209ffb['message'],_0x2a1074);_0x46432c(_0x21a05f['error'](0x1f4,_0x209ffb[_0xb670('0x10')]));});});};