8d594c500050c78ce4783171de5455b8e0f0d293
[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 _0x1ac4=['ChatMessage','create','body','options','stringify','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','defaults','socket.io-emitter','redis','request','then','ChatMessage,\x20%s,\x20%s','request\x20sent','debug','ChatMessage,\x20%s,\x20%s,\x20%s','error','code','message','info','result','catch','CreateChatMessage'];(function(_0xbb9dbf,_0x5dafa4){var _0x30223c=function(_0xaa9ca){while(--_0xaa9ca){_0xbb9dbf['push'](_0xbb9dbf['shift']());}};_0x30223c(++_0x5dafa4);}(_0x1ac4,0xa5));var _0x41ac=function(_0x1999f8,_0x533cd9){_0x1999f8=_0x1999f8-0x0;var _0x565134=_0x1ac4[_0x1999f8];return _0x565134;};'use strict';var _=require(_0x41ac('0x0'));var util=require(_0x41ac('0x1'));var moment=require(_0x41ac('0x2'));var BPromise=require('bluebird');var rs=require(_0x41ac('0x3'));var fs=require('fs');var Redis=require(_0x41ac('0x4'));var db=require(_0x41ac('0x5'))['db'];var utils=require(_0x41ac('0x6'));var logger=require(_0x41ac('0x7'))(_0x41ac('0x8'));var config=require(_0x41ac('0x9'));var jayson=require(_0x41ac('0xa'));var client=jayson['client']['http']({'port':0x232a});config['redis']=_[_0x41ac('0xb')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x41ac('0xc'))(new Redis(config[_0x41ac('0xd')]));require('./chatMessage.socket')['register'](socket);function respondWithRpcPromise(_0x53a556,_0x2321b9,_0x4bb727){return new BPromise(function(_0x2eb14f,_0x124d77){return client[_0x41ac('0xe')](_0x53a556,_0x4bb727)[_0x41ac('0xf')](function(_0x55f614){logger['info'](_0x41ac('0x10'),_0x2321b9,_0x41ac('0x11'));logger[_0x41ac('0x12')](_0x41ac('0x13'),_0x2321b9,'request\x20sent',JSON['stringify'](_0x55f614));if(_0x55f614[_0x41ac('0x14')]){if(_0x55f614[_0x41ac('0x14')][_0x41ac('0x15')]===0x1f4){logger['error'](_0x41ac('0x10'),_0x2321b9,_0x55f614[_0x41ac('0x14')][_0x41ac('0x16')]);return _0x124d77(_0x55f614['error'][_0x41ac('0x16')]);}logger[_0x41ac('0x14')](_0x41ac('0x10'),_0x2321b9,_0x55f614[_0x41ac('0x14')][_0x41ac('0x16')]);return _0x2eb14f(_0x55f614[_0x41ac('0x14')][_0x41ac('0x16')]);}else{logger[_0x41ac('0x17')]('ChatMessage,\x20%s,\x20%s',_0x2321b9,'request\x20sent');_0x2eb14f(_0x55f614[_0x41ac('0x18')][_0x41ac('0x16')]);}})[_0x41ac('0x19')](function(_0xff8a13){logger[_0x41ac('0x14')](_0x41ac('0x10'),_0x2321b9,_0xff8a13);_0x124d77(_0xff8a13);});});}exports[_0x41ac('0x1a')]=function(_0xf26d58){var _0x3a4036=this;return new Promise(function(_0x10ad98,_0x6eee23){return db[_0x41ac('0x1b')][_0x41ac('0x1c')](_0xf26d58[_0x41ac('0x1d')],{'raw':_0xf26d58['options']?_0xf26d58[_0x41ac('0x1e')]['raw']===undefined?!![]:![]:!![]})[_0x41ac('0xf')](function(_0x57b174){logger[_0x41ac('0x17')](_0x41ac('0x1a'),_0xf26d58);logger[_0x41ac('0x12')](_0x41ac('0x1a'),_0xf26d58,JSON[_0x41ac('0x1f')](_0x57b174));_0x10ad98(_0x57b174);})[_0x41ac('0x19')](function(_0x57593c){logger['error']('CreateChatMessage',_0x57593c['message'],_0xf26d58);_0x6eee23(_0x3a4036['error'](0x1f4,_0x57593c[_0x41ac('0x16')]));});});};