Built motion from commit da24aabd.|2.6.20
[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 _0x0b06=['client','http','redis','defaults','socket.io-emitter','./chatMessage.socket','then','info','ChatMessage,\x20%s,\x20%s','request\x20sent','debug','ChatMessage,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','CreateChatMessage','ChatMessage','body','options','raw','stringify','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x856298,_0x456bdb){var _0x2ba365=function(_0xfb7655){while(--_0xfb7655){_0x856298['push'](_0x856298['shift']());}};_0x2ba365(++_0x456bdb);}(_0x0b06,0x11f));var _0x60b0=function(_0x4fc956,_0xccc2fe){_0x4fc956=_0x4fc956-0x0;var _0x3d914d=_0x0b06[_0x4fc956];return _0x3d914d;};'use strict';var _=require(_0x60b0('0x0'));var util=require(_0x60b0('0x1'));var moment=require(_0x60b0('0x2'));var BPromise=require(_0x60b0('0x3'));var rs=require(_0x60b0('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x60b0('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x60b0('0x6'))(_0x60b0('0x7'));var config=require(_0x60b0('0x8'));var jayson=require(_0x60b0('0x9'));var client=jayson[_0x60b0('0xa')][_0x60b0('0xb')]({'port':0x232a});config[_0x60b0('0xc')]=_[_0x60b0('0xd')](config[_0x60b0('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0x60b0('0xe'))(new Redis(config[_0x60b0('0xc')]));require(_0x60b0('0xf'))['register'](socket);function respondWithRpcPromise(_0x5e1ba5,_0x14691c,_0x542716){return new BPromise(function(_0x44f793,_0x50aefb){return client['request'](_0x5e1ba5,_0x542716)[_0x60b0('0x10')](function(_0x5c3a49){logger[_0x60b0('0x11')](_0x60b0('0x12'),_0x14691c,_0x60b0('0x13'));logger[_0x60b0('0x14')](_0x60b0('0x15'),_0x14691c,_0x60b0('0x13'),JSON['stringify'](_0x5c3a49));if(_0x5c3a49[_0x60b0('0x16')]){if(_0x5c3a49[_0x60b0('0x16')][_0x60b0('0x17')]===0x1f4){logger[_0x60b0('0x16')]('ChatMessage,\x20%s,\x20%s',_0x14691c,_0x5c3a49[_0x60b0('0x16')][_0x60b0('0x18')]);return _0x50aefb(_0x5c3a49[_0x60b0('0x16')][_0x60b0('0x18')]);}logger[_0x60b0('0x16')]('ChatMessage,\x20%s,\x20%s',_0x14691c,_0x5c3a49['error'][_0x60b0('0x18')]);return _0x44f793(_0x5c3a49['error'][_0x60b0('0x18')]);}else{logger['info'](_0x60b0('0x12'),_0x14691c,'request\x20sent');_0x44f793(_0x5c3a49[_0x60b0('0x19')][_0x60b0('0x18')]);}})[_0x60b0('0x1a')](function(_0x21eee5){logger[_0x60b0('0x16')]('ChatMessage,\x20%s,\x20%s',_0x14691c,_0x21eee5);_0x50aefb(_0x21eee5);});});}exports[_0x60b0('0x1b')]=function(_0x5a1acc){var _0x405fe0=this;return new Promise(function(_0x378a7f,_0x3c5f4c){return db[_0x60b0('0x1c')]['create'](_0x5a1acc[_0x60b0('0x1d')],{'raw':_0x5a1acc[_0x60b0('0x1e')]?_0x5a1acc[_0x60b0('0x1e')][_0x60b0('0x1f')]===undefined?!![]:![]:!![]})[_0x60b0('0x10')](function(_0x5d4081){logger['info'](_0x60b0('0x1b'),_0x5a1acc);logger[_0x60b0('0x14')](_0x60b0('0x1b'),_0x5a1acc,JSON[_0x60b0('0x20')](_0x5d4081));_0x378a7f(_0x5d4081);})[_0x60b0('0x1a')](function(_0x21acd6){logger[_0x60b0('0x16')](_0x60b0('0x1b'),_0x21acd6['message'],_0x5a1acc);_0x3c5f4c(_0x405fe0[_0x60b0('0x16')](0x1f4,_0x21acd6['message']));});});};