aaefc2bb09e4bc022ae3a39795de5ab794ceb276
[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 _0xc41d=['raw','debug','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','client','redis','defaults','localhost','socket.io-emitter','./chatMessage.socket','register','request','then','info','ChatMessage,\x20%s,\x20%s','request\x20sent','ChatMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','CreateChatMessage','ChatMessage','create','options'];(function(_0xabf9a7,_0x15e853){var _0x2263a3=function(_0x39a98f){while(--_0x39a98f){_0xabf9a7['push'](_0xabf9a7['shift']());}};_0x2263a3(++_0x15e853);}(_0xc41d,0x86));var _0xdc41=function(_0x58f689,_0x22ff0e){_0x58f689=_0x58f689-0x0;var _0x1fefa5=_0xc41d[_0x58f689];return _0x1fefa5;};'use strict';var _=require(_0xdc41('0x0'));var util=require(_0xdc41('0x1'));var moment=require(_0xdc41('0x2'));var BPromise=require(_0xdc41('0x3'));var rs=require(_0xdc41('0x4'));var fs=require('fs');var Redis=require(_0xdc41('0x5'));var db=require(_0xdc41('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xdc41('0x7'));var config=require(_0xdc41('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xdc41('0x9')]['http']({'port':0x232a});config[_0xdc41('0xa')]=_[_0xdc41('0xb')](config[_0xdc41('0xa')],{'host':_0xdc41('0xc'),'port':0x18eb});var socket=require(_0xdc41('0xd'))(new Redis(config['redis']));require(_0xdc41('0xe'))[_0xdc41('0xf')](socket);function respondWithRpcPromise(_0x4bc1db,_0xb99135,_0x4b7331){return new BPromise(function(_0x15b5af,_0x55c3f9){return client[_0xdc41('0x10')](_0x4bc1db,_0x4b7331)[_0xdc41('0x11')](function(_0x1637e2){logger[_0xdc41('0x12')](_0xdc41('0x13'),_0xb99135,_0xdc41('0x14'));logger['debug'](_0xdc41('0x15'),_0xb99135,_0xdc41('0x14'),JSON[_0xdc41('0x16')](_0x1637e2));if(_0x1637e2[_0xdc41('0x17')]){if(_0x1637e2['error'][_0xdc41('0x18')]===0x1f4){logger[_0xdc41('0x17')]('ChatMessage,\x20%s,\x20%s',_0xb99135,_0x1637e2[_0xdc41('0x17')][_0xdc41('0x19')]);return _0x55c3f9(_0x1637e2[_0xdc41('0x17')][_0xdc41('0x19')]);}logger['error'](_0xdc41('0x13'),_0xb99135,_0x1637e2['error'][_0xdc41('0x19')]);return _0x15b5af(_0x1637e2[_0xdc41('0x17')][_0xdc41('0x19')]);}else{logger[_0xdc41('0x12')](_0xdc41('0x13'),_0xb99135,_0xdc41('0x14'));_0x15b5af(_0x1637e2['result'][_0xdc41('0x19')]);}})[_0xdc41('0x1a')](function(_0x278f43){logger['error'](_0xdc41('0x13'),_0xb99135,_0x278f43);_0x55c3f9(_0x278f43);});});}exports[_0xdc41('0x1b')]=function(_0x3bedd7){var _0x8477cc=this;return new Promise(function(_0x22af20,_0x31e40f){return db[_0xdc41('0x1c')][_0xdc41('0x1d')](_0x3bedd7['body'],{'raw':_0x3bedd7[_0xdc41('0x1e')]?_0x3bedd7[_0xdc41('0x1e')][_0xdc41('0x1f')]===undefined?!![]:![]:!![]})[_0xdc41('0x11')](function(_0x396b0c){logger[_0xdc41('0x12')](_0xdc41('0x1b'),_0x3bedd7);logger[_0xdc41('0x20')](_0xdc41('0x1b'),_0x3bedd7,JSON[_0xdc41('0x16')](_0x396b0c));_0x22af20(_0x396b0c);})[_0xdc41('0x1a')](function(_0x3d4a67){logger['error'](_0xdc41('0x1b'),_0x3d4a67[_0xdc41('0x19')],_0x3bedd7);_0x31e40f(_0x8477cc['error'](0x1f4,_0x3d4a67[_0xdc41('0x19')]));});});};