Built motion from commit (unavailable).|2.5.14
[motion2.git] / server / api / chatMessage / chatMessage.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 _0x01c7=['../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','redis','localhost','./chatMessage.socket','then','ChatMessage,\x20%s,\x20%s','debug','ChatMessage,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','catch','CreateChatMessage','ChatMessage','create','options','raw','lodash','util','moment','bluebird','randomstring','ioredis'];(function(_0xdf9a3,_0x59b0ab){var _0xe01d17=function(_0x1c8dd6){while(--_0x1c8dd6){_0xdf9a3['push'](_0xdf9a3['shift']());}};_0xe01d17(++_0x59b0ab);}(_0x01c7,0x1e9));var _0x701c=function(_0x574af1,_0x53c393){_0x574af1=_0x574af1-0x0;var _0x2b8672=_0x01c7[_0x574af1];return _0x2b8672;};'use strict';var _=require(_0x701c('0x0'));var util=require(_0x701c('0x1'));var moment=require(_0x701c('0x2'));var BPromise=require(_0x701c('0x3'));var rs=require(_0x701c('0x4'));var fs=require('fs');var Redis=require(_0x701c('0x5'));var db=require(_0x701c('0x6'))['db'];var utils=require(_0x701c('0x7'));var logger=require(_0x701c('0x8'))(_0x701c('0x9'));var config=require('../../config/environment');var jayson=require(_0x701c('0xa'));var client=jayson[_0x701c('0xb')][_0x701c('0xc')]({'port':0x232a});config[_0x701c('0xd')]=_['defaults'](config['redis'],{'host':_0x701c('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x701c('0xd')]));require(_0x701c('0xf'))['register'](socket);function respondWithRpcPromise(_0x264f8b,_0x416dcc,_0x531d24){return new BPromise(function(_0x256ff4,_0x35f573){return client['request'](_0x264f8b,_0x531d24)[_0x701c('0x10')](function(_0x4d5b46){logger['info'](_0x701c('0x11'),_0x416dcc,'request\x20sent');logger[_0x701c('0x12')](_0x701c('0x13'),_0x416dcc,_0x701c('0x14'),JSON[_0x701c('0x15')](_0x4d5b46));if(_0x4d5b46['error']){if(_0x4d5b46[_0x701c('0x16')][_0x701c('0x17')]===0x1f4){logger[_0x701c('0x16')]('ChatMessage,\x20%s,\x20%s',_0x416dcc,_0x4d5b46[_0x701c('0x16')][_0x701c('0x18')]);return _0x35f573(_0x4d5b46['error'][_0x701c('0x18')]);}logger[_0x701c('0x16')](_0x701c('0x11'),_0x416dcc,_0x4d5b46[_0x701c('0x16')][_0x701c('0x18')]);return _0x256ff4(_0x4d5b46[_0x701c('0x16')][_0x701c('0x18')]);}else{logger[_0x701c('0x19')](_0x701c('0x11'),_0x416dcc,'request\x20sent');_0x256ff4(_0x4d5b46[_0x701c('0x1a')][_0x701c('0x18')]);}})[_0x701c('0x1b')](function(_0x407b3c){logger[_0x701c('0x16')](_0x701c('0x11'),_0x416dcc,_0x407b3c);_0x35f573(_0x407b3c);});});}exports[_0x701c('0x1c')]=function(_0x148c5a){var _0x266874=this;return new Promise(function(_0xb114de,_0x4939f8){return db[_0x701c('0x1d')][_0x701c('0x1e')](_0x148c5a['body'],{'raw':_0x148c5a[_0x701c('0x1f')]?_0x148c5a['options'][_0x701c('0x20')]===undefined?!![]:![]:!![]})[_0x701c('0x10')](function(_0x665ceb){logger[_0x701c('0x19')](_0x701c('0x1c'),_0x148c5a);logger['debug'](_0x701c('0x1c'),_0x148c5a,JSON[_0x701c('0x15')](_0x665ceb));_0xb114de(_0x665ceb);})[_0x701c('0x1b')](function(_0x1b1493){logger[_0x701c('0x16')](_0x701c('0x1c'),_0x1b1493[_0x701c('0x18')],_0x148c5a);_0x4939f8(_0x266874[_0x701c('0x16')](0x1f4,_0x1b1493[_0x701c('0x18')]));});});};