90a5ee49381d5fe51201144384934c465f45aa84
[motion2.git] / server / api / chatInternalMessage / chatInternalMessage.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 _0xac0b=['../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','socket.io-emitter','./chatInternalMessage.socket','request','then','ChatInternalMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','info','result','catch','lodash','util','moment','randomstring','ioredis'];(function(_0x109dc3,_0xf6b661){var _0x41a1c=function(_0x558639){while(--_0x558639){_0x109dc3['push'](_0x109dc3['shift']());}};_0x41a1c(++_0xf6b661);}(_0xac0b,0x109));var _0xbac0=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0xac0b[_0x122ef9];return _0x42fba0;};'use strict';var _=require(_0xbac0('0x0'));var util=require(_0xbac0('0x1'));var moment=require(_0xbac0('0x2'));var BPromise=require('bluebird');var rs=require(_0xbac0('0x3'));var fs=require('fs');var Redis=require(_0xbac0('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xbac0('0x5'));var logger=require(_0xbac0('0x6'))(_0xbac0('0x7'));var config=require(_0xbac0('0x8'));var jayson=require(_0xbac0('0x9'));var client=jayson[_0xbac0('0xa')][_0xbac0('0xb')]({'port':0x232a});config['redis']=_['defaults'](config[_0xbac0('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0xbac0('0xd'))(new Redis(config['redis']));require(_0xbac0('0xe'))['register'](socket);function respondWithRpcPromise(_0x4fdca7,_0x4b29c3,_0x4cede9){return new BPromise(function(_0x3d830d,_0x10ff41){return client[_0xbac0('0xf')](_0x4fdca7,_0x4cede9)[_0xbac0('0x10')](function(_0x424297){logger['info'](_0xbac0('0x11'),_0x4b29c3,_0xbac0('0x12'));logger[_0xbac0('0x13')]('ChatInternalMessage,\x20%s,\x20%s,\x20%s',_0x4b29c3,_0xbac0('0x12'),JSON[_0xbac0('0x14')](_0x424297));if(_0x424297[_0xbac0('0x15')]){if(_0x424297[_0xbac0('0x15')][_0xbac0('0x16')]===0x1f4){logger[_0xbac0('0x15')](_0xbac0('0x11'),_0x4b29c3,_0x424297['error']['message']);return _0x10ff41(_0x424297[_0xbac0('0x15')][_0xbac0('0x17')]);}logger[_0xbac0('0x15')](_0xbac0('0x11'),_0x4b29c3,_0x424297['error'][_0xbac0('0x17')]);return _0x3d830d(_0x424297['error'][_0xbac0('0x17')]);}else{logger[_0xbac0('0x18')](_0xbac0('0x11'),_0x4b29c3,'request\x20sent');_0x3d830d(_0x424297[_0xbac0('0x19')][_0xbac0('0x17')]);}})[_0xbac0('0x1a')](function(_0x1f6038){logger[_0xbac0('0x15')](_0xbac0('0x11'),_0x4b29c3,_0x1f6038);_0x10ff41(_0x1f6038);});});}