e960a4c82df2102601bdf0e815da4bc4b304f240
[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 _0x406b=['CannedAnswer,\x20%s,\x20%s','request\x20sent','debug','CannedAnswer,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','request','then','info'];(function(_0x13885f,_0x4ba84e){var _0x192362=function(_0x188e9d){while(--_0x188e9d){_0x13885f['push'](_0x13885f['shift']());}};_0x192362(++_0x4ba84e);}(_0x406b,0x179));var _0xb406=function(_0xae7c2f,_0xf31e04){_0xae7c2f=_0xae7c2f-0x0;var _0x5d7001=_0x406b[_0xae7c2f];return _0x5d7001;};'use strict';var _=require(_0xb406('0x0'));var util=require(_0xb406('0x1'));var moment=require(_0xb406('0x2'));var BPromise=require(_0xb406('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb406('0x4'));var db=require(_0xb406('0x5'))['db'];var utils=require(_0xb406('0x6'));var logger=require(_0xb406('0x7'))(_0xb406('0x8'));var config=require(_0xb406('0x9'));var jayson=require('jayson/promise');var client=jayson[_0xb406('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x3b8390,_0x281537,_0xd41d2e){return new BPromise(function(_0x3a9ee1,_0x42d4d9){return client[_0xb406('0xb')](_0x3b8390,_0xd41d2e)[_0xb406('0xc')](function(_0x27e783){logger[_0xb406('0xd')](_0xb406('0xe'),_0x281537,_0xb406('0xf'));logger[_0xb406('0x10')](_0xb406('0x11'),_0x281537,_0xb406('0xf'),JSON[_0xb406('0x12')](_0x27e783));if(_0x27e783[_0xb406('0x13')]){if(_0x27e783['error'][_0xb406('0x14')]===0x1f4){logger['error'](_0xb406('0xe'),_0x281537,_0x27e783['error'][_0xb406('0x15')]);return _0x42d4d9(_0x27e783[_0xb406('0x13')][_0xb406('0x15')]);}logger[_0xb406('0x13')](_0xb406('0xe'),_0x281537,_0x27e783[_0xb406('0x13')][_0xb406('0x15')]);return _0x3a9ee1(_0x27e783[_0xb406('0x13')][_0xb406('0x15')]);}else{logger[_0xb406('0xd')](_0xb406('0xe'),_0x281537,_0xb406('0xf'));_0x3a9ee1(_0x27e783[_0xb406('0x16')][_0xb406('0x15')]);}})['catch'](function(_0x127ead){logger[_0xb406('0x13')](_0xb406('0xe'),_0x281537,_0x127ead);_0x42d4d9(_0x127ead);});});}