79871a0abebbc6110bcf3fcb7d0abc53d7e7743b
[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 _0xe5ca=['jayson/promise','client','http','then','CannedAnswer,\x20%s,\x20%s','request\x20sent','debug','error','code','message','info','catch','moment','bluebird','ioredis','../../config/utils','../../config/logger','../../config/environment'];(function(_0x533587,_0x35049e){var _0x512bc3=function(_0x1ccff6){while(--_0x1ccff6){_0x533587['push'](_0x533587['shift']());}};_0x512bc3(++_0x35049e);}(_0xe5ca,0x1ce));var _0xae5c=function(_0xd511d,_0x3546b9){_0xd511d=_0xd511d-0x0;var _0x3f148e=_0xe5ca[_0xd511d];return _0x3f148e;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xae5c('0x0'));var BPromise=require(_0xae5c('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xae5c('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0xae5c('0x3'));var logger=require(_0xae5c('0x4'))('rpc');var config=require(_0xae5c('0x5'));var jayson=require(_0xae5c('0x6'));var client=jayson[_0xae5c('0x7')][_0xae5c('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x5c19f9,_0x1fb46b,_0x113f0a){return new BPromise(function(_0x14529e,_0x19f19f){return client['request'](_0x5c19f9,_0x113f0a)[_0xae5c('0x9')](function(_0xdbfd71){logger['info'](_0xae5c('0xa'),_0x1fb46b,_0xae5c('0xb'));logger[_0xae5c('0xc')]('CannedAnswer,\x20%s,\x20%s,\x20%s',_0x1fb46b,_0xae5c('0xb'),JSON['stringify'](_0xdbfd71));if(_0xdbfd71['error']){if(_0xdbfd71[_0xae5c('0xd')][_0xae5c('0xe')]===0x1f4){logger[_0xae5c('0xd')](_0xae5c('0xa'),_0x1fb46b,_0xdbfd71[_0xae5c('0xd')][_0xae5c('0xf')]);return _0x19f19f(_0xdbfd71[_0xae5c('0xd')]['message']);}logger['error']('CannedAnswer,\x20%s,\x20%s',_0x1fb46b,_0xdbfd71[_0xae5c('0xd')][_0xae5c('0xf')]);return _0x14529e(_0xdbfd71['error'][_0xae5c('0xf')]);}else{logger[_0xae5c('0x10')](_0xae5c('0xa'),_0x1fb46b,_0xae5c('0xb'));_0x14529e(_0xdbfd71['result'][_0xae5c('0xf')]);}})[_0xae5c('0x11')](function(_0x59fb4b){logger[_0xae5c('0xd')](_0xae5c('0xa'),_0x1fb46b,_0x59fb4b);_0x19f19f(_0x59fb4b);});});}