c01766f657a171530aaa3f30bcd15a13f5a5eab9
[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 _0x81f1=['jayson/promise','client','http','redis','socket.io-emitter','./chatMessage.socket','register','request','then','info','request\x20sent','ChatMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','ChatMessage,\x20%s,\x20%s','message','result','catch','CreateChatMessage','ChatMessage','create','body','options','raw','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment'];(function(_0x432682,_0x253044){var _0x463d05=function(_0xa73403){while(--_0xa73403){_0x432682['push'](_0x432682['shift']());}};_0x463d05(++_0x253044);}(_0x81f1,0x129));var _0x181f=function(_0x5c63a4,_0x496024){_0x5c63a4=_0x5c63a4-0x0;var _0x557ae1=_0x81f1[_0x5c63a4];return _0x557ae1;};'use strict';var _=require(_0x181f('0x0'));var util=require(_0x181f('0x1'));var moment=require(_0x181f('0x2'));var BPromise=require(_0x181f('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x181f('0x4'))['db'];var utils=require(_0x181f('0x5'));var logger=require(_0x181f('0x6'))(_0x181f('0x7'));var config=require(_0x181f('0x8'));var jayson=require(_0x181f('0x9'));var client=jayson[_0x181f('0xa')][_0x181f('0xb')]({'port':0x232a});config[_0x181f('0xc')]=_['defaults'](config[_0x181f('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0x181f('0xd'))(new Redis(config['redis']));require(_0x181f('0xe'))[_0x181f('0xf')](socket);function respondWithRpcPromise(_0x5e7462,_0xb7451,_0x23c983){return new BPromise(function(_0x138dab,_0x2b70aa){return client[_0x181f('0x10')](_0x5e7462,_0x23c983)[_0x181f('0x11')](function(_0x94bd12){logger[_0x181f('0x12')]('ChatMessage,\x20%s,\x20%s',_0xb7451,_0x181f('0x13'));logger['debug'](_0x181f('0x14'),_0xb7451,_0x181f('0x13'),JSON[_0x181f('0x15')](_0x94bd12));if(_0x94bd12[_0x181f('0x16')]){if(_0x94bd12[_0x181f('0x16')][_0x181f('0x17')]===0x1f4){logger[_0x181f('0x16')](_0x181f('0x18'),_0xb7451,_0x94bd12[_0x181f('0x16')][_0x181f('0x19')]);return _0x2b70aa(_0x94bd12['error']['message']);}logger[_0x181f('0x16')](_0x181f('0x18'),_0xb7451,_0x94bd12[_0x181f('0x16')][_0x181f('0x19')]);return _0x138dab(_0x94bd12['error'][_0x181f('0x19')]);}else{logger['info']('ChatMessage,\x20%s,\x20%s',_0xb7451,'request\x20sent');_0x138dab(_0x94bd12[_0x181f('0x1a')][_0x181f('0x19')]);}})[_0x181f('0x1b')](function(_0x47d686){logger[_0x181f('0x16')](_0x181f('0x18'),_0xb7451,_0x47d686);_0x2b70aa(_0x47d686);});});}exports[_0x181f('0x1c')]=function(_0x4cdca7){var _0x3dd6ff=this;return new Promise(function(_0x27e8ed,_0xdd604){return db[_0x181f('0x1d')][_0x181f('0x1e')](_0x4cdca7[_0x181f('0x1f')],{'raw':_0x4cdca7[_0x181f('0x20')]?_0x4cdca7['options'][_0x181f('0x21')]===undefined?!![]:![]:!![]})[_0x181f('0x11')](function(_0x5f1eb7){logger[_0x181f('0x12')](_0x181f('0x1c'),_0x4cdca7);logger['debug'](_0x181f('0x1c'),_0x4cdca7,JSON['stringify'](_0x5f1eb7));_0x27e8ed(_0x5f1eb7);})['catch'](function(_0x2e654b){logger[_0x181f('0x16')](_0x181f('0x1c'),_0x2e654b[_0x181f('0x19')],_0x4cdca7);_0xdd604(_0x3dd6ff['error'](0x1f4,_0x2e654b[_0x181f('0x19')]));});});};