Built motion from commit (unavailable).|2.5.20
[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 _0xba35=['../../config/environment','jayson/promise','client','http','request','then','request\x20sent','debug','stringify','error','code','Pause,\x20%s,\x20%s','message','info','result','catch','ShowPause','options','raw','include','map','model','attributes','lodash','util','moment','bluebird','../../mysqldb','rpc'];(function(_0xb2c3c2,_0x1d0ff7){var _0x42ff7c=function(_0x2eaddf){while(--_0x2eaddf){_0xb2c3c2['push'](_0xb2c3c2['shift']());}};_0x42ff7c(++_0x1d0ff7);}(_0xba35,0x190));var _0x5ba3=function(_0x167cc1,_0x56ef5a){_0x167cc1=_0x167cc1-0x0;var _0x10bc4b=_0xba35[_0x167cc1];return _0x10bc4b;};'use strict';var _=require(_0x5ba3('0x0'));var util=require(_0x5ba3('0x1'));var moment=require(_0x5ba3('0x2'));var BPromise=require(_0x5ba3('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x5ba3('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x5ba3('0x5'));var config=require(_0x5ba3('0x6'));var jayson=require(_0x5ba3('0x7'));var client=jayson[_0x5ba3('0x8')][_0x5ba3('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x34d847,_0x3b83f1,_0x462ede){return new BPromise(function(_0x2d563c,_0x8e2b0e){return client[_0x5ba3('0xa')](_0x34d847,_0x462ede)[_0x5ba3('0xb')](function(_0x155c28){logger['info']('Pause,\x20%s,\x20%s',_0x3b83f1,_0x5ba3('0xc'));logger[_0x5ba3('0xd')]('Pause,\x20%s,\x20%s,\x20%s',_0x3b83f1,_0x5ba3('0xc'),JSON[_0x5ba3('0xe')](_0x155c28));if(_0x155c28[_0x5ba3('0xf')]){if(_0x155c28[_0x5ba3('0xf')][_0x5ba3('0x10')]===0x1f4){logger[_0x5ba3('0xf')](_0x5ba3('0x11'),_0x3b83f1,_0x155c28[_0x5ba3('0xf')]['message']);return _0x8e2b0e(_0x155c28['error'][_0x5ba3('0x12')]);}logger[_0x5ba3('0xf')](_0x5ba3('0x11'),_0x3b83f1,_0x155c28[_0x5ba3('0xf')][_0x5ba3('0x12')]);return _0x2d563c(_0x155c28[_0x5ba3('0xf')][_0x5ba3('0x12')]);}else{logger[_0x5ba3('0x13')](_0x5ba3('0x11'),_0x3b83f1,_0x5ba3('0xc'));_0x2d563c(_0x155c28[_0x5ba3('0x14')]['message']);}})[_0x5ba3('0x15')](function(_0xb61c16){logger[_0x5ba3('0xf')](_0x5ba3('0x11'),_0x3b83f1,_0xb61c16);_0x8e2b0e(_0xb61c16);});});}exports[_0x5ba3('0x16')]=function(_0x9e9344){var _0xd574b1=this;return new Promise(function(_0x519645,_0x2ff5ab){return db['Pause']['find']({'raw':_0x9e9344[_0x5ba3('0x17')]?_0x9e9344[_0x5ba3('0x17')][_0x5ba3('0x18')]===undefined?!![]:![]:!![],'where':_0x9e9344[_0x5ba3('0x17')]?_0x9e9344[_0x5ba3('0x17')]['where']||null:null,'attributes':_0x9e9344[_0x5ba3('0x17')]?_0x9e9344[_0x5ba3('0x17')]['attributes']||null:null,'include':_0x9e9344[_0x5ba3('0x17')]?_0x9e9344[_0x5ba3('0x17')][_0x5ba3('0x19')]?_[_0x5ba3('0x1a')](_0x9e9344[_0x5ba3('0x17')][_0x5ba3('0x19')],function(_0x4c2f02){return{'model':db[_0x4c2f02[_0x5ba3('0x1b')]],'as':_0x4c2f02['as'],'attributes':_0x4c2f02[_0x5ba3('0x1c')],'include':_0x4c2f02[_0x5ba3('0x19')]?_[_0x5ba3('0x1a')](_0x4c2f02['include'],function(_0x16e1b3){return{'model':db[_0x16e1b3['model']],'as':_0x16e1b3['as'],'attributes':_0x16e1b3['attributes'],'include':_0x16e1b3[_0x5ba3('0x19')]?_['map'](_0x16e1b3[_0x5ba3('0x19')],function(_0x166493){return{'model':db[_0x166493[_0x5ba3('0x1b')]],'as':_0x166493['as'],'attributes':_0x166493['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x214f1d){logger[_0x5ba3('0x13')](_0x5ba3('0x16'),_0x9e9344);logger['debug'](_0x5ba3('0x16'),_0x9e9344,JSON[_0x5ba3('0xe')](_0x214f1d));_0x519645(_0x214f1d);})[_0x5ba3('0x15')](function(_0x3b09a0){logger[_0x5ba3('0xf')]('ShowPause',_0x3b09a0[_0x5ba3('0x12')],_0x9e9344);_0x2ff5ab(_0xd574b1[_0x5ba3('0xf')](0x1f4,_0x3b09a0['message']));});});};