096333eb3ce5f62b053e4d379d28e017cc31de8d
[motion2.git] / server / api / chatApplication / chatApplication.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 _0x781a=['request\x20sent','stringify','error','message','result','catch','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','info','ChatApplication,\x20%s,\x20%s','debug','ChatApplication,\x20%s,\x20%s,\x20%s'];(function(_0xd5f814,_0x1da457){var _0x119b7c=function(_0x2a8f31){while(--_0x2a8f31){_0xd5f814['push'](_0xd5f814['shift']());}};_0x119b7c(++_0x1da457);}(_0x781a,0xd8));var _0xa781=function(_0x13c8c4,_0x27a9cf){_0x13c8c4=_0x13c8c4-0x0;var _0x40c8dd=_0x781a[_0x13c8c4];return _0x40c8dd;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0xa781('0x0'));var rs=require(_0xa781('0x1'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xa781('0x2'))['db'];var utils=require(_0xa781('0x3'));var logger=require(_0xa781('0x4'))(_0xa781('0x5'));var config=require(_0xa781('0x6'));var jayson=require(_0xa781('0x7'));var client=jayson[_0xa781('0x8')][_0xa781('0x9')]({'port':0x232a});function respondWithRpcPromise(_0xcd2713,_0x56fa4b,_0x1615e5){return new BPromise(function(_0x5bbec0,_0x43cdc9){return client[_0xa781('0xa')](_0xcd2713,_0x1615e5)['then'](function(_0x2632a9){logger[_0xa781('0xb')](_0xa781('0xc'),_0x56fa4b,'request\x20sent');logger[_0xa781('0xd')](_0xa781('0xe'),_0x56fa4b,_0xa781('0xf'),JSON[_0xa781('0x10')](_0x2632a9));if(_0x2632a9[_0xa781('0x11')]){if(_0x2632a9[_0xa781('0x11')]['code']===0x1f4){logger[_0xa781('0x11')](_0xa781('0xc'),_0x56fa4b,_0x2632a9['error'][_0xa781('0x12')]);return _0x43cdc9(_0x2632a9['error'][_0xa781('0x12')]);}logger[_0xa781('0x11')](_0xa781('0xc'),_0x56fa4b,_0x2632a9[_0xa781('0x11')]['message']);return _0x5bbec0(_0x2632a9['error']['message']);}else{logger[_0xa781('0xb')](_0xa781('0xc'),_0x56fa4b,_0xa781('0xf'));_0x5bbec0(_0x2632a9[_0xa781('0x13')][_0xa781('0x12')]);}})[_0xa781('0x14')](function(_0x307349){logger[_0xa781('0x11')](_0xa781('0xc'),_0x56fa4b,_0x307349);_0x43cdc9(_0x307349);});});}