5117bcaf8b59df6c31679b9399839820055c5b48
[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 _0x56ff=['error','Pause,\x20%s,\x20%s','message','info','result','ShowPause','find','options','raw','where','attributes','include','map','model','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','debug','Pause,\x20%s,\x20%s,\x20%s','request\x20sent','stringify'];(function(_0xf2c425,_0xbdceae){var _0x2f8aae=function(_0x511748){while(--_0x511748){_0xf2c425['push'](_0xf2c425['shift']());}};_0x2f8aae(++_0xbdceae);}(_0x56ff,0xb9));var _0xf56f=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x56ff[_0x20a584];return _0x4b41a8;};'use strict';var _=require(_0xf56f('0x0'));var util=require(_0xf56f('0x1'));var moment=require(_0xf56f('0x2'));var BPromise=require(_0xf56f('0x3'));var rs=require(_0xf56f('0x4'));var fs=require('fs');var Redis=require(_0xf56f('0x5'));var db=require(_0xf56f('0x6'))['db'];var utils=require(_0xf56f('0x7'));var logger=require(_0xf56f('0x8'))(_0xf56f('0x9'));var config=require(_0xf56f('0xa'));var jayson=require(_0xf56f('0xb'));var client=jayson['client'][_0xf56f('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x262f62,_0x5b7e43,_0x164491){return new BPromise(function(_0x4c6d7b,_0x151501){return client[_0xf56f('0xd')](_0x262f62,_0x164491)[_0xf56f('0xe')](function(_0x2c896c){logger['info']('Pause,\x20%s,\x20%s',_0x5b7e43,'request\x20sent');logger[_0xf56f('0xf')](_0xf56f('0x10'),_0x5b7e43,_0xf56f('0x11'),JSON[_0xf56f('0x12')](_0x2c896c));if(_0x2c896c['error']){if(_0x2c896c['error']['code']===0x1f4){logger[_0xf56f('0x13')](_0xf56f('0x14'),_0x5b7e43,_0x2c896c[_0xf56f('0x13')][_0xf56f('0x15')]);return _0x151501(_0x2c896c[_0xf56f('0x13')][_0xf56f('0x15')]);}logger['error']('Pause,\x20%s,\x20%s',_0x5b7e43,_0x2c896c[_0xf56f('0x13')][_0xf56f('0x15')]);return _0x4c6d7b(_0x2c896c[_0xf56f('0x13')][_0xf56f('0x15')]);}else{logger[_0xf56f('0x16')](_0xf56f('0x14'),_0x5b7e43,_0xf56f('0x11'));_0x4c6d7b(_0x2c896c[_0xf56f('0x17')][_0xf56f('0x15')]);}})['catch'](function(_0x5aae9e){logger[_0xf56f('0x13')](_0xf56f('0x14'),_0x5b7e43,_0x5aae9e);_0x151501(_0x5aae9e);});});}exports[_0xf56f('0x18')]=function(_0x195de9){var _0x3b8008=this;return new Promise(function(_0x51a150,_0x154056){return db['Pause'][_0xf56f('0x19')]({'raw':_0x195de9[_0xf56f('0x1a')]?_0x195de9['options'][_0xf56f('0x1b')]===undefined?!![]:![]:!![],'where':_0x195de9['options']?_0x195de9[_0xf56f('0x1a')][_0xf56f('0x1c')]||null:null,'attributes':_0x195de9[_0xf56f('0x1a')]?_0x195de9[_0xf56f('0x1a')][_0xf56f('0x1d')]||null:null,'include':_0x195de9['options']?_0x195de9[_0xf56f('0x1a')][_0xf56f('0x1e')]?_[_0xf56f('0x1f')](_0x195de9[_0xf56f('0x1a')][_0xf56f('0x1e')],function(_0x50d0e9){return{'model':db[_0x50d0e9['model']],'as':_0x50d0e9['as'],'attributes':_0x50d0e9[_0xf56f('0x1d')],'include':_0x50d0e9[_0xf56f('0x1e')]?_['map'](_0x50d0e9[_0xf56f('0x1e')],function(_0x55ba46){return{'model':db[_0x55ba46[_0xf56f('0x20')]],'as':_0x55ba46['as'],'attributes':_0x55ba46['attributes'],'include':_0x55ba46['include']?_[_0xf56f('0x1f')](_0x55ba46[_0xf56f('0x1e')],function(_0x105415){return{'model':db[_0x105415['model']],'as':_0x105415['as'],'attributes':_0x105415[_0xf56f('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xf56f('0xe')](function(_0x1f5199){logger[_0xf56f('0x16')](_0xf56f('0x18'),_0x195de9);logger[_0xf56f('0xf')](_0xf56f('0x18'),_0x195de9,JSON[_0xf56f('0x12')](_0x1f5199));_0x51a150(_0x1f5199);})[_0xf56f('0x21')](function(_0x4148f6){logger['error']('ShowPause',_0x4148f6['message'],_0x195de9);_0x154056(_0x3b8008['error'](0x1f4,_0x4148f6[_0xf56f('0x15')]));});});};