14fe00446bbe4afd314d140a5b503f6b61c9417b
[motion2.git] / server / api / chatGroup / chatGroup.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 _0xd7ce=['request','then','info','ChatGroup,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','code','ChatGroup,\x20%s,\x20%s','error','message','result','catch','lodash','util','moment','bluebird','../../mysqldb','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./chatGroup.socket','register'];(function(_0x2f3421,_0x15ef52){var _0x41c577=function(_0x51ca15){while(--_0x51ca15){_0x2f3421['push'](_0x2f3421['shift']());}};_0x41c577(++_0x15ef52);}(_0xd7ce,0x16b));var _0xed7c=function(_0x373dee,_0x1a8c45){_0x373dee=_0x373dee-0x0;var _0x46798f=_0xd7ce[_0x373dee];return _0x46798f;};'use strict';var _=require(_0xed7c('0x0'));var util=require(_0xed7c('0x1'));var moment=require(_0xed7c('0x2'));var BPromise=require(_0xed7c('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xed7c('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0xed7c('0x5'));var jayson=require(_0xed7c('0x6'));var client=jayson[_0xed7c('0x7')][_0xed7c('0x8')]({'port':0x232a});config[_0xed7c('0x9')]=_[_0xed7c('0xa')](config[_0xed7c('0x9')],{'host':_0xed7c('0xb'),'port':0x18eb});var socket=require(_0xed7c('0xc'))(new Redis(config[_0xed7c('0x9')]));require(_0xed7c('0xd'))[_0xed7c('0xe')](socket);function respondWithRpcPromise(_0x5beb1c,_0x3902d9,_0x1e337e){return new BPromise(function(_0x30867e,_0x425a81){return client[_0xed7c('0xf')](_0x5beb1c,_0x1e337e)[_0xed7c('0x10')](function(_0x5f431b){logger[_0xed7c('0x11')]('ChatGroup,\x20%s,\x20%s',_0x3902d9,'request\x20sent');logger['debug'](_0xed7c('0x12'),_0x3902d9,_0xed7c('0x13'),JSON[_0xed7c('0x14')](_0x5f431b));if(_0x5f431b['error']){if(_0x5f431b['error'][_0xed7c('0x15')]===0x1f4){logger['error'](_0xed7c('0x16'),_0x3902d9,_0x5f431b[_0xed7c('0x17')]['message']);return _0x425a81(_0x5f431b[_0xed7c('0x17')][_0xed7c('0x18')]);}logger['error']('ChatGroup,\x20%s,\x20%s',_0x3902d9,_0x5f431b[_0xed7c('0x17')][_0xed7c('0x18')]);return _0x30867e(_0x5f431b[_0xed7c('0x17')]['message']);}else{logger['info'](_0xed7c('0x16'),_0x3902d9,_0xed7c('0x13'));_0x30867e(_0x5f431b[_0xed7c('0x19')][_0xed7c('0x18')]);}})[_0xed7c('0x1a')](function(_0x396555){logger[_0xed7c('0x17')](_0xed7c('0x16'),_0x3902d9,_0x396555);_0x425a81(_0x396555);});});}