3a591fe55c12c9b41eb3e3618a76e877456ecb03
[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 _0x18fa=['info','ChatApplication,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','result','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client','http','then'];(function(_0x3c933d,_0x15d7dd){var _0x3d7e19=function(_0x4115d1){while(--_0x4115d1){_0x3c933d['push'](_0x3c933d['shift']());}};_0x3d7e19(++_0x15d7dd);}(_0x18fa,0x188));var _0xa18f=function(_0x28301f,_0x3572d7){_0x28301f=_0x28301f-0x0;var _0x3665ec=_0x18fa[_0x28301f];return _0x3665ec;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xa18f('0x0'));var db=require(_0xa18f('0x1'))['db'];var utils=require(_0xa18f('0x2'));var logger=require(_0xa18f('0x3'))(_0xa18f('0x4'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xa18f('0x5')][_0xa18f('0x6')]({'port':0x232a});function respondWithRpcPromise(_0x1a125f,_0x3a78f6,_0x4076d5){return new BPromise(function(_0x5a675f,_0x5ad0bd){return client['request'](_0x1a125f,_0x4076d5)[_0xa18f('0x7')](function(_0x281fca){logger[_0xa18f('0x8')](_0xa18f('0x9'),_0x3a78f6,_0xa18f('0xa'));logger[_0xa18f('0xb')]('ChatApplication,\x20%s,\x20%s,\x20%s',_0x3a78f6,_0xa18f('0xa'),JSON[_0xa18f('0xc')](_0x281fca));if(_0x281fca[_0xa18f('0xd')]){if(_0x281fca['error']['code']===0x1f4){logger[_0xa18f('0xd')]('ChatApplication,\x20%s,\x20%s',_0x3a78f6,_0x281fca[_0xa18f('0xd')][_0xa18f('0xe')]);return _0x5ad0bd(_0x281fca[_0xa18f('0xd')][_0xa18f('0xe')]);}logger[_0xa18f('0xd')](_0xa18f('0x9'),_0x3a78f6,_0x281fca[_0xa18f('0xd')][_0xa18f('0xe')]);return _0x5a675f(_0x281fca['error'][_0xa18f('0xe')]);}else{logger[_0xa18f('0x8')](_0xa18f('0x9'),_0x3a78f6,'request\x20sent');_0x5a675f(_0x281fca[_0xa18f('0xf')][_0xa18f('0xe')]);}})['catch'](function(_0x38a55b){logger['error'](_0xa18f('0x9'),_0x3a78f6,_0x38a55b);_0x5ad0bd(_0x38a55b);});});}