1b3f3f46e8e9c51e1e0e482af9c0cf5ea2573f58
[motion2.git] / server / api / chatWebsite / chatWebsite.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 _0x80f1=['ChatWebsite,\x20%s,\x20%s','message','result','catch','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','redis','localhost','request','info','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','code'];(function(_0x361282,_0x30cdc8){var _0x278740=function(_0x21f8f5){while(--_0x21f8f5){_0x361282['push'](_0x361282['shift']());}};_0x278740(++_0x30cdc8);}(_0x80f1,0x1d8));var _0x180f=function(_0x2a0d33,_0x1fc7a7){_0x2a0d33=_0x2a0d33-0x0;var _0x4be3ef=_0x80f1[_0x2a0d33];return _0x4be3ef;};'use strict';var _=require(_0x180f('0x0'));var util=require(_0x180f('0x1'));var moment=require(_0x180f('0x2'));var BPromise=require(_0x180f('0x3'));var rs=require(_0x180f('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x180f('0x5'))['db'];var utils=require(_0x180f('0x6'));var logger=require(_0x180f('0x7'))(_0x180f('0x8'));var config=require('../../config/environment');var jayson=require(_0x180f('0x9'));var client=jayson[_0x180f('0xa')][_0x180f('0xb')]({'port':0x232a});config[_0x180f('0xc')]=_['defaults'](config['redis'],{'host':_0x180f('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x180f('0xc')]));require('./chatWebsite.socket')['register'](socket);function respondWithRpcPromise(_0xe6defe,_0x2a6036,_0x19ea4d){return new BPromise(function(_0xc05db1,_0x4de7cb){return client[_0x180f('0xe')](_0xe6defe,_0x19ea4d)['then'](function(_0x442403){logger[_0x180f('0xf')]('ChatWebsite,\x20%s,\x20%s',_0x2a6036,_0x180f('0x10'));logger[_0x180f('0x11')](_0x180f('0x12'),_0x2a6036,_0x180f('0x10'),JSON[_0x180f('0x13')](_0x442403));if(_0x442403[_0x180f('0x14')]){if(_0x442403['error'][_0x180f('0x15')]===0x1f4){logger['error'](_0x180f('0x16'),_0x2a6036,_0x442403['error'][_0x180f('0x17')]);return _0x4de7cb(_0x442403[_0x180f('0x14')][_0x180f('0x17')]);}logger['error'](_0x180f('0x16'),_0x2a6036,_0x442403[_0x180f('0x14')][_0x180f('0x17')]);return _0xc05db1(_0x442403[_0x180f('0x14')][_0x180f('0x17')]);}else{logger[_0x180f('0xf')](_0x180f('0x16'),_0x2a6036,_0x180f('0x10'));_0xc05db1(_0x442403[_0x180f('0x18')][_0x180f('0x17')]);}})[_0x180f('0x19')](function(_0x59d537){logger[_0x180f('0x14')](_0x180f('0x16'),_0x2a6036,_0x59d537);_0x4de7cb(_0x59d537);});});}