9d56b11a67fdcf948cdc53b135786ab1c49f5ce7
[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 _0xf397=['defaults','localhost','./chatWebsite.socket','request','then','info','request\x20sent','ChatWebsite,\x20%s,\x20%s,\x20%s','error','code','ChatWebsite,\x20%s,\x20%s','message','result','catch','lodash','util','moment','bluebird','randomstring','../../mysqldb','rpc','../../config/environment','jayson/promise','http','redis'];(function(_0x53e166,_0x2c9dd6){var _0x4605a7=function(_0x1e9e86){while(--_0x1e9e86){_0x53e166['push'](_0x53e166['shift']());}};_0x4605a7(++_0x2c9dd6);}(_0xf397,0xef));var _0x7f39=function(_0x501ddb,_0xd3a1c7){_0x501ddb=_0x501ddb-0x0;var _0x5b390f=_0xf397[_0x501ddb];return _0x5b390f;};'use strict';var _=require(_0x7f39('0x0'));var util=require(_0x7f39('0x1'));var moment=require(_0x7f39('0x2'));var BPromise=require(_0x7f39('0x3'));var rs=require(_0x7f39('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x7f39('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x7f39('0x6'));var config=require(_0x7f39('0x7'));var jayson=require(_0x7f39('0x8'));var client=jayson['client'][_0x7f39('0x9')]({'port':0x232a});config[_0x7f39('0xa')]=_[_0x7f39('0xb')](config[_0x7f39('0xa')],{'host':_0x7f39('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x7f39('0xd'))['register'](socket);function respondWithRpcPromise(_0x2247e7,_0x13ba0c,_0x394f49){return new BPromise(function(_0x2c6c31,_0x326201){return client[_0x7f39('0xe')](_0x2247e7,_0x394f49)[_0x7f39('0xf')](function(_0x5e2b60){logger[_0x7f39('0x10')]('ChatWebsite,\x20%s,\x20%s',_0x13ba0c,_0x7f39('0x11'));logger['debug'](_0x7f39('0x12'),_0x13ba0c,_0x7f39('0x11'),JSON['stringify'](_0x5e2b60));if(_0x5e2b60[_0x7f39('0x13')]){if(_0x5e2b60[_0x7f39('0x13')][_0x7f39('0x14')]===0x1f4){logger[_0x7f39('0x13')](_0x7f39('0x15'),_0x13ba0c,_0x5e2b60[_0x7f39('0x13')]['message']);return _0x326201(_0x5e2b60[_0x7f39('0x13')][_0x7f39('0x16')]);}logger[_0x7f39('0x13')]('ChatWebsite,\x20%s,\x20%s',_0x13ba0c,_0x5e2b60[_0x7f39('0x13')][_0x7f39('0x16')]);return _0x2c6c31(_0x5e2b60[_0x7f39('0x13')][_0x7f39('0x16')]);}else{logger['info'](_0x7f39('0x15'),_0x13ba0c,_0x7f39('0x11'));_0x2c6c31(_0x5e2b60[_0x7f39('0x17')]['message']);}})[_0x7f39('0x18')](function(_0x55e65a){logger[_0x7f39('0x13')](_0x7f39('0x15'),_0x13ba0c,_0x55e65a);_0x326201(_0x55e65a);});});}