Built motion from commit (unavailable).|2.4.3
[motion2.git] / server / api / saRequest / saRequest.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 _0x1f76=['util','moment','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','client','http','then','SARequest,\x20%s,\x20%s,\x20%s','stringify','error','message','SARequest,\x20%s,\x20%s','catch'];(function(_0x8df2d2,_0x590380){var _0xcdf8f3=function(_0x471b49){while(--_0x471b49){_0x8df2d2['push'](_0x8df2d2['shift']());}};_0xcdf8f3(++_0x590380);}(_0x1f76,0x160));var _0x61f7=function(_0x1a5f62,_0xfd8370){_0x1a5f62=_0x1a5f62-0x0;var _0x431cf7=_0x1f76[_0x1a5f62];return _0x431cf7;};'use strict';var _=require('lodash');var util=require(_0x61f7('0x0'));var moment=require(_0x61f7('0x1'));var BPromise=require('bluebird');var rs=require(_0x61f7('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x61f7('0x3'))['db'];var utils=require(_0x61f7('0x4'));var logger=require(_0x61f7('0x5'))(_0x61f7('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x61f7('0x7')][_0x61f7('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x2b77ae,_0x4a231e,_0x552e3a){return new BPromise(function(_0x2b6a69,_0x10f49f){return client['request'](_0x2b77ae,_0x552e3a)[_0x61f7('0x9')](function(_0x42f740){logger['info']('SARequest,\x20%s,\x20%s',_0x4a231e,'request\x20sent');logger['debug'](_0x61f7('0xa'),_0x4a231e,'request\x20sent',JSON[_0x61f7('0xb')](_0x42f740));if(_0x42f740['error']){if(_0x42f740[_0x61f7('0xc')]['code']===0x1f4){logger['error']('SARequest,\x20%s,\x20%s',_0x4a231e,_0x42f740[_0x61f7('0xc')][_0x61f7('0xd')]);return _0x10f49f(_0x42f740[_0x61f7('0xc')][_0x61f7('0xd')]);}logger['error'](_0x61f7('0xe'),_0x4a231e,_0x42f740['error'][_0x61f7('0xd')]);return _0x2b6a69(_0x42f740[_0x61f7('0xc')][_0x61f7('0xd')]);}else{logger['info'](_0x61f7('0xe'),_0x4a231e,'request\x20sent');_0x2b6a69(_0x42f740['result'][_0x61f7('0xd')]);}})[_0x61f7('0xf')](function(_0x3e6bd9){logger[_0x61f7('0xc')](_0x61f7('0xe'),_0x4a231e,_0x3e6bd9);_0x10f49f(_0x3e6bd9);});});}