e4e7db1797914186c7f7404de8050fd54a6b453f
[motion2.git] / server / api / schedule / schedule.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 _0xa6b7=['moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','client','http','request','then','info','request\x20sent','stringify','error','Schedule,\x20%s,\x20%s','message','catch','lodash'];(function(_0x5734f9,_0x3ec8d9){var _0x1f8bcb=function(_0x44f2a3){while(--_0x44f2a3){_0x5734f9['push'](_0x5734f9['shift']());}};_0x1f8bcb(++_0x3ec8d9);}(_0xa6b7,0x84));var _0x7a6b=function(_0x2bc3f4,_0x470b26){_0x2bc3f4=_0x2bc3f4-0x0;var _0x14ac53=_0xa6b7[_0x2bc3f4];return _0x14ac53;};'use strict';var _=require(_0x7a6b('0x0'));var util=require('util');var moment=require(_0x7a6b('0x1'));var BPromise=require(_0x7a6b('0x2'));var rs=require(_0x7a6b('0x3'));var fs=require('fs');var Redis=require(_0x7a6b('0x4'));var db=require(_0x7a6b('0x5'))['db'];var utils=require(_0x7a6b('0x6'));var logger=require(_0x7a6b('0x7'))('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x7a6b('0x8')][_0x7a6b('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x1d3c06,_0x413240,_0x36ecbd){return new BPromise(function(_0x1269aa,_0x57dbda){return client[_0x7a6b('0xa')](_0x1d3c06,_0x36ecbd)[_0x7a6b('0xb')](function(_0xbb8b18){logger[_0x7a6b('0xc')]('Schedule,\x20%s,\x20%s',_0x413240,_0x7a6b('0xd'));logger['debug']('Schedule,\x20%s,\x20%s,\x20%s',_0x413240,_0x7a6b('0xd'),JSON[_0x7a6b('0xe')](_0xbb8b18));if(_0xbb8b18[_0x7a6b('0xf')]){if(_0xbb8b18[_0x7a6b('0xf')]['code']===0x1f4){logger[_0x7a6b('0xf')](_0x7a6b('0x10'),_0x413240,_0xbb8b18[_0x7a6b('0xf')][_0x7a6b('0x11')]);return _0x57dbda(_0xbb8b18[_0x7a6b('0xf')][_0x7a6b('0x11')]);}logger[_0x7a6b('0xf')](_0x7a6b('0x10'),_0x413240,_0xbb8b18[_0x7a6b('0xf')][_0x7a6b('0x11')]);return _0x1269aa(_0xbb8b18[_0x7a6b('0xf')]['message']);}else{logger['info'](_0x7a6b('0x10'),_0x413240,_0x7a6b('0xd'));_0x1269aa(_0xbb8b18['result']['message']);}})[_0x7a6b('0x12')](function(_0x916598){logger['error'](_0x7a6b('0x10'),_0x413240,_0x916598);_0x57dbda(_0x916598);});});}