Built motion from commit (unavailable).|2.5.30
[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 _0x8773=['rpc','../../config/environment','http','then','CannedAnswer,\x20%s,\x20%s','request\x20sent','CannedAnswer,\x20%s,\x20%s,\x20%s','error','message','info','result','catch','util','moment','randomstring','ioredis','../../config/utils','../../config/logger'];(function(_0x23285e,_0x24434c){var _0x33ce43=function(_0x150c16){while(--_0x150c16){_0x23285e['push'](_0x23285e['shift']());}};_0x33ce43(++_0x24434c);}(_0x8773,0x198));var _0x3877=function(_0x1a7768,_0x515b35){_0x1a7768=_0x1a7768-0x0;var _0x1df5fa=_0x8773[_0x1a7768];return _0x1df5fa;};'use strict';var _=require('lodash');var util=require(_0x3877('0x0'));var moment=require(_0x3877('0x1'));var BPromise=require('bluebird');var rs=require(_0x3877('0x2'));var fs=require('fs');var Redis=require(_0x3877('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x3877('0x4'));var logger=require(_0x3877('0x5'))(_0x3877('0x6'));var config=require(_0x3877('0x7'));var jayson=require('jayson/promise');var client=jayson['client'][_0x3877('0x8')]({'port':0x232a});function respondWithRpcPromise(_0xa70d8,_0xa38f61,_0xee561d){return new BPromise(function(_0x531790,_0x3c40){return client['request'](_0xa70d8,_0xee561d)[_0x3877('0x9')](function(_0x4fabeb){logger['info'](_0x3877('0xa'),_0xa38f61,_0x3877('0xb'));logger['debug'](_0x3877('0xc'),_0xa38f61,_0x3877('0xb'),JSON['stringify'](_0x4fabeb));if(_0x4fabeb['error']){if(_0x4fabeb[_0x3877('0xd')]['code']===0x1f4){logger[_0x3877('0xd')](_0x3877('0xa'),_0xa38f61,_0x4fabeb[_0x3877('0xd')][_0x3877('0xe')]);return _0x3c40(_0x4fabeb['error'][_0x3877('0xe')]);}logger['error'](_0x3877('0xa'),_0xa38f61,_0x4fabeb['error'][_0x3877('0xe')]);return _0x531790(_0x4fabeb[_0x3877('0xd')][_0x3877('0xe')]);}else{logger[_0x3877('0xf')](_0x3877('0xa'),_0xa38f61,'request\x20sent');_0x531790(_0x4fabeb[_0x3877('0x10')]['message']);}})[_0x3877('0x11')](function(_0x3a35ce){logger['error'](_0x3877('0xa'),_0xa38f61,_0x3a35ce);_0x3c40(_0x3a35ce);});});}