7b455cb9a715ffd6b52228ce235b2c571fbac6dd
[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 _0x5939=['../../config/utils','rpc','../../config/environment','client','defaults','redis','localhost','./chatWebsite.socket','register','request','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','ChatWebsite,\x20%s,\x20%s,\x20%s','error','code','message','util','moment','randomstring','../../mysqldb'];(function(_0xa7c370,_0x2de929){var _0x206e54=function(_0x5ae91f){while(--_0x5ae91f){_0xa7c370['push'](_0xa7c370['shift']());}};_0x206e54(++_0x2de929);}(_0x5939,0x11a));var _0x9593=function(_0x1e95fe,_0x138cd5){_0x1e95fe=_0x1e95fe-0x0;var _0xaaafc8=_0x5939[_0x1e95fe];return _0xaaafc8;};'use strict';var _=require('lodash');var util=require(_0x9593('0x0'));var moment=require(_0x9593('0x1'));var BPromise=require('bluebird');var rs=require(_0x9593('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x9593('0x3'))['db'];var utils=require(_0x9593('0x4'));var logger=require('../../config/logger')(_0x9593('0x5'));var config=require(_0x9593('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x9593('0x7')]['http']({'port':0x232a});config['redis']=_[_0x9593('0x8')](config[_0x9593('0x9')],{'host':_0x9593('0xa'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x9593('0x9')]));require(_0x9593('0xb'))[_0x9593('0xc')](socket);function respondWithRpcPromise(_0x1f34f0,_0x2908d8,_0x3ea2d4){return new BPromise(function(_0x153e15,_0x421245){return client[_0x9593('0xd')](_0x1f34f0,_0x3ea2d4)[_0x9593('0xe')](function(_0x1a79ec){logger[_0x9593('0xf')](_0x9593('0x10'),_0x2908d8,_0x9593('0x11'));logger['debug'](_0x9593('0x12'),_0x2908d8,'request\x20sent',JSON['stringify'](_0x1a79ec));if(_0x1a79ec[_0x9593('0x13')]){if(_0x1a79ec['error'][_0x9593('0x14')]===0x1f4){logger['error'](_0x9593('0x10'),_0x2908d8,_0x1a79ec[_0x9593('0x13')][_0x9593('0x15')]);return _0x421245(_0x1a79ec[_0x9593('0x13')]['message']);}logger['error'](_0x9593('0x10'),_0x2908d8,_0x1a79ec[_0x9593('0x13')]['message']);return _0x153e15(_0x1a79ec[_0x9593('0x13')][_0x9593('0x15')]);}else{logger[_0x9593('0xf')](_0x9593('0x10'),_0x2908d8,'request\x20sent');_0x153e15(_0x1a79ec['result'][_0x9593('0x15')]);}})['catch'](function(_0x5e63cc){logger[_0x9593('0x13')]('ChatWebsite,\x20%s,\x20%s',_0x2908d8,_0x5e63cc);_0x421245(_0x5e63cc);});});}