52f2eabffac09a9af72b739124d9c188fae4c782
[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 _0x104f=['randomstring','ioredis','../../mysqldb','../../config/utils','client','http','request','then','info','debug','CannedAnswer,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','CannedAnswer,\x20%s,\x20%s','result','catch','lodash','util','moment'];(function(_0x45783c,_0x49c56d){var _0x1161da=function(_0x3c5d41){while(--_0x3c5d41){_0x45783c['push'](_0x45783c['shift']());}};_0x1161da(++_0x49c56d);}(_0x104f,0x97));var _0xf104=function(_0x6d24c6,_0x5e9a31){_0x6d24c6=_0x6d24c6-0x0;var _0x59eb38=_0x104f[_0x6d24c6];return _0x59eb38;};'use strict';var _=require(_0xf104('0x0'));var util=require(_0xf104('0x1'));var moment=require(_0xf104('0x2'));var BPromise=require('bluebird');var rs=require(_0xf104('0x3'));var fs=require('fs');var Redis=require(_0xf104('0x4'));var db=require(_0xf104('0x5'))['db'];var utils=require(_0xf104('0x6'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xf104('0x7')][_0xf104('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x7d7b2a,_0xe4aeb6,_0x179686){return new BPromise(function(_0x542c5b,_0xd15524){return client[_0xf104('0x9')](_0x7d7b2a,_0x179686)[_0xf104('0xa')](function(_0x4dd04e){logger[_0xf104('0xb')]('CannedAnswer,\x20%s,\x20%s',_0xe4aeb6,'request\x20sent');logger[_0xf104('0xc')](_0xf104('0xd'),_0xe4aeb6,_0xf104('0xe'),JSON[_0xf104('0xf')](_0x4dd04e));if(_0x4dd04e[_0xf104('0x10')]){if(_0x4dd04e[_0xf104('0x10')][_0xf104('0x11')]===0x1f4){logger[_0xf104('0x10')]('CannedAnswer,\x20%s,\x20%s',_0xe4aeb6,_0x4dd04e[_0xf104('0x10')]['message']);return _0xd15524(_0x4dd04e['error'][_0xf104('0x12')]);}logger[_0xf104('0x10')](_0xf104('0x13'),_0xe4aeb6,_0x4dd04e[_0xf104('0x10')][_0xf104('0x12')]);return _0x542c5b(_0x4dd04e[_0xf104('0x10')][_0xf104('0x12')]);}else{logger[_0xf104('0xb')]('CannedAnswer,\x20%s,\x20%s',_0xe4aeb6,_0xf104('0xe'));_0x542c5b(_0x4dd04e[_0xf104('0x14')][_0xf104('0x12')]);}})[_0xf104('0x15')](function(_0x4c9804){logger[_0xf104('0x10')](_0xf104('0x13'),_0xe4aeb6,_0x4c9804);_0xd15524(_0x4c9804);});});}