15710b9b373b262554b23af975a8529166cf5490
[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 _0x2d53=['../../config/utils','../../config/logger','rpc','client','http','info','CannedAnswer,\x20%s,\x20%s','request\x20sent','CannedAnswer,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','lodash','util','moment','bluebird','../../mysqldb'];(function(_0x4bd1d0,_0x17c43f){var _0x1fea67=function(_0x9eb66c){while(--_0x9eb66c){_0x4bd1d0['push'](_0x4bd1d0['shift']());}};_0x1fea67(++_0x17c43f);}(_0x2d53,0x1c3));var _0x32d5=function(_0x1c1172,_0x27c3c4){_0x1c1172=_0x1c1172-0x0;var _0x300943=_0x2d53[_0x1c1172];return _0x300943;};'use strict';var _=require(_0x32d5('0x0'));var util=require(_0x32d5('0x1'));var moment=require(_0x32d5('0x2'));var BPromise=require(_0x32d5('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x32d5('0x4'))['db'];var utils=require(_0x32d5('0x5'));var logger=require(_0x32d5('0x6'))(_0x32d5('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x32d5('0x8')][_0x32d5('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x2f5546,_0x297217,_0x590ccf){return new BPromise(function(_0x5585e1,_0x3ef505){return client['request'](_0x2f5546,_0x590ccf)['then'](function(_0x3bdb41){logger[_0x32d5('0xa')](_0x32d5('0xb'),_0x297217,_0x32d5('0xc'));logger['debug'](_0x32d5('0xd'),_0x297217,_0x32d5('0xc'),JSON['stringify'](_0x3bdb41));if(_0x3bdb41[_0x32d5('0xe')]){if(_0x3bdb41[_0x32d5('0xe')][_0x32d5('0xf')]===0x1f4){logger[_0x32d5('0xe')](_0x32d5('0xb'),_0x297217,_0x3bdb41[_0x32d5('0xe')]['message']);return _0x3ef505(_0x3bdb41[_0x32d5('0xe')][_0x32d5('0x10')]);}logger[_0x32d5('0xe')](_0x32d5('0xb'),_0x297217,_0x3bdb41[_0x32d5('0xe')][_0x32d5('0x10')]);return _0x5585e1(_0x3bdb41[_0x32d5('0xe')][_0x32d5('0x10')]);}else{logger[_0x32d5('0xa')]('CannedAnswer,\x20%s,\x20%s',_0x297217,'request\x20sent');_0x5585e1(_0x3bdb41[_0x32d5('0x11')][_0x32d5('0x10')]);}})[_0x32d5('0x12')](function(_0x81c3d8){logger[_0x32d5('0xe')](_0x32d5('0xb'),_0x297217,_0x81c3d8);_0x3ef505(_0x81c3d8);});});}