766449be43fff5d83231709cb077be1b7f64c0fb
[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 _0x20ff=['defaults','localhost','./chatGroup.socket','register','then','info','ChatGroup,\x20%s,\x20%s','request\x20sent','debug','code','error','message','catch','util','bluebird','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis'];(function(_0x381478,_0x5dfc86){var _0x5743d5=function(_0x57f242){while(--_0x57f242){_0x381478['push'](_0x381478['shift']());}};_0x5743d5(++_0x5dfc86);}(_0x20ff,0x166));var _0xf20f=function(_0x4f3b4b,_0x590f08){_0x4f3b4b=_0x4f3b4b-0x0;var _0x1249e0=_0x20ff[_0x4f3b4b];return _0x1249e0;};'use strict';var _=require('lodash');var util=require(_0xf20f('0x0'));var moment=require('moment');var BPromise=require(_0xf20f('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xf20f('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0xf20f('0x3'));var logger=require(_0xf20f('0x4'))(_0xf20f('0x5'));var config=require(_0xf20f('0x6'));var jayson=require(_0xf20f('0x7'));var client=jayson['client'][_0xf20f('0x8')]({'port':0x232a});config[_0xf20f('0x9')]=_[_0xf20f('0xa')](config['redis'],{'host':_0xf20f('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xf20f('0xc'))[_0xf20f('0xd')](socket);function respondWithRpcPromise(_0x2519d8,_0x55603e,_0x92590c){return new BPromise(function(_0x56dcc7,_0x231e2b){return client['request'](_0x2519d8,_0x92590c)[_0xf20f('0xe')](function(_0x5a80b3){logger[_0xf20f('0xf')](_0xf20f('0x10'),_0x55603e,_0xf20f('0x11'));logger[_0xf20f('0x12')]('ChatGroup,\x20%s,\x20%s,\x20%s',_0x55603e,_0xf20f('0x11'),JSON['stringify'](_0x5a80b3));if(_0x5a80b3['error']){if(_0x5a80b3['error'][_0xf20f('0x13')]===0x1f4){logger[_0xf20f('0x14')](_0xf20f('0x10'),_0x55603e,_0x5a80b3[_0xf20f('0x14')][_0xf20f('0x15')]);return _0x231e2b(_0x5a80b3[_0xf20f('0x14')]['message']);}logger[_0xf20f('0x14')](_0xf20f('0x10'),_0x55603e,_0x5a80b3[_0xf20f('0x14')][_0xf20f('0x15')]);return _0x56dcc7(_0x5a80b3[_0xf20f('0x14')]['message']);}else{logger[_0xf20f('0xf')]('ChatGroup,\x20%s,\x20%s',_0x55603e,'request\x20sent');_0x56dcc7(_0x5a80b3['result']['message']);}})[_0xf20f('0x16')](function(_0x179c89){logger[_0xf20f('0x14')](_0xf20f('0x10'),_0x55603e,_0x179c89);_0x231e2b(_0x179c89);});});}