42c862e677111e0dcc818f63cff2eb64a2fc47f2
[motion2.git] / server / api / chatInternalMessage / chatInternalMessage.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 _0x0c88=['message','result','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','defaults','localhost','register','then','info','ChatInternalMessage,\x20%s,\x20%s','request\x20sent','ChatInternalMessage,\x20%s,\x20%s,\x20%s','stringify','error','code'];(function(_0x336e94,_0x101b3f){var _0x321fb7=function(_0x1abcfe){while(--_0x1abcfe){_0x336e94['push'](_0x336e94['shift']());}};_0x321fb7(++_0x101b3f);}(_0x0c88,0x1dd));var _0x80c8=function(_0x49b207,_0x408ade){_0x49b207=_0x49b207-0x0;var _0x2dc8fa=_0x0c88[_0x49b207];return _0x2dc8fa;};'use strict';var _=require(_0x80c8('0x0'));var util=require(_0x80c8('0x1'));var moment=require('moment');var BPromise=require(_0x80c8('0x2'));var rs=require(_0x80c8('0x3'));var fs=require('fs');var Redis=require(_0x80c8('0x4'));var db=require(_0x80c8('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x80c8('0x6'))(_0x80c8('0x7'));var config=require(_0x80c8('0x8'));var jayson=require(_0x80c8('0x9'));var client=jayson[_0x80c8('0xa')][_0x80c8('0xb')]({'port':0x232a});config['redis']=_[_0x80c8('0xc')](config['redis'],{'host':_0x80c8('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./chatInternalMessage.socket')[_0x80c8('0xe')](socket);function respondWithRpcPromise(_0x490d89,_0x4b2b53,_0x23d836){return new BPromise(function(_0x2b322e,_0x3160ac){return client['request'](_0x490d89,_0x23d836)[_0x80c8('0xf')](function(_0x47e788){logger[_0x80c8('0x10')](_0x80c8('0x11'),_0x4b2b53,_0x80c8('0x12'));logger['debug'](_0x80c8('0x13'),_0x4b2b53,_0x80c8('0x12'),JSON[_0x80c8('0x14')](_0x47e788));if(_0x47e788[_0x80c8('0x15')]){if(_0x47e788['error'][_0x80c8('0x16')]===0x1f4){logger[_0x80c8('0x15')](_0x80c8('0x11'),_0x4b2b53,_0x47e788[_0x80c8('0x15')][_0x80c8('0x17')]);return _0x3160ac(_0x47e788['error']['message']);}logger[_0x80c8('0x15')]('ChatInternalMessage,\x20%s,\x20%s',_0x4b2b53,_0x47e788[_0x80c8('0x15')][_0x80c8('0x17')]);return _0x2b322e(_0x47e788[_0x80c8('0x15')]['message']);}else{logger[_0x80c8('0x10')](_0x80c8('0x11'),_0x4b2b53,'request\x20sent');_0x2b322e(_0x47e788[_0x80c8('0x18')][_0x80c8('0x17')]);}})['catch'](function(_0x3127c6){logger[_0x80c8('0x15')](_0x80c8('0x11'),_0x4b2b53,_0x3127c6);_0x3160ac(_0x3127c6);});});}