6e9018a5c9569cc5fca8330fd37a63f108bf2a44
[motion2.git] / server / api / cannedAnswer / cannedAnswer.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 _0x8f40=['ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','request','then','CannedAnswer,\x20%s,\x20%s','request\x20sent','CannedAnswer,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','util','moment','bluebird','randomstring'];(function(_0x3f4568,_0x9eb0ee){var _0xee2340=function(_0xdefabb){while(--_0xdefabb){_0x3f4568['push'](_0x3f4568['shift']());}};_0xee2340(++_0x9eb0ee);}(_0x8f40,0xec));var _0x08f4=function(_0x32c5d8,_0x6004b7){_0x32c5d8=_0x32c5d8-0x0;var _0x5973b9=_0x8f40[_0x32c5d8];return _0x5973b9;};'use strict';var _=require('lodash');var util=require(_0x08f4('0x0'));var moment=require(_0x08f4('0x1'));var BPromise=require(_0x08f4('0x2'));var rs=require(_0x08f4('0x3'));var fs=require('fs');var Redis=require(_0x08f4('0x4'));var db=require(_0x08f4('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x08f4('0x6'))('rpc');var config=require(_0x08f4('0x7'));var jayson=require(_0x08f4('0x8'));var client=jayson[_0x08f4('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2aeb6d,_0x5352c3,_0x3f493c){return new BPromise(function(_0x502785,_0x35b532){return client[_0x08f4('0xa')](_0x2aeb6d,_0x3f493c)[_0x08f4('0xb')](function(_0x2b2862){logger['info'](_0x08f4('0xc'),_0x5352c3,_0x08f4('0xd'));logger['debug'](_0x08f4('0xe'),_0x5352c3,_0x08f4('0xd'),JSON[_0x08f4('0xf')](_0x2b2862));if(_0x2b2862['error']){if(_0x2b2862[_0x08f4('0x10')][_0x08f4('0x11')]===0x1f4){logger['error'](_0x08f4('0xc'),_0x5352c3,_0x2b2862[_0x08f4('0x10')][_0x08f4('0x12')]);return _0x35b532(_0x2b2862[_0x08f4('0x10')]['message']);}logger['error']('CannedAnswer,\x20%s,\x20%s',_0x5352c3,_0x2b2862['error'][_0x08f4('0x12')]);return _0x502785(_0x2b2862[_0x08f4('0x10')][_0x08f4('0x12')]);}else{logger['info']('CannedAnswer,\x20%s,\x20%s',_0x5352c3,_0x08f4('0xd'));_0x502785(_0x2b2862['result'][_0x08f4('0x12')]);}})[_0x08f4('0x13')](function(_0x1d01a1){logger[_0x08f4('0x10')](_0x08f4('0xc'),_0x5352c3,_0x1d01a1);_0x35b532(_0x1d01a1);});});}