5c37e0863fea9b76d5169dddcd124a5a275835d8
[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 _0xf70b=['raw','lodash','util','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','defaults','redis','socket.io-emitter','./chatMessage.socket','register','request','then','info','ChatMessage,\x20%s,\x20%s','request\x20sent','debug','ChatMessage,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','CreateChatMessage','ChatMessage','create','body','options'];(function(_0x330e8c,_0x469ba5){var _0x150a9b=function(_0xe9731e){while(--_0xe9731e){_0x330e8c['push'](_0x330e8c['shift']());}};_0x150a9b(++_0x469ba5);}(_0xf70b,0x64));var _0xbf70=function(_0x17e773,_0x5908aa){_0x17e773=_0x17e773-0x0;var _0x9c7640=_0xf70b[_0x17e773];return _0x9c7640;};'use strict';var _=require(_0xbf70('0x0'));var util=require(_0xbf70('0x1'));var moment=require('moment');var BPromise=require(_0xbf70('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xbf70('0x3'))['db'];var utils=require(_0xbf70('0x4'));var logger=require(_0xbf70('0x5'))(_0xbf70('0x6'));var config=require(_0xbf70('0x7'));var jayson=require(_0xbf70('0x8'));var client=jayson['client'][_0xbf70('0x9')]({'port':0x232a});config['redis']=_[_0xbf70('0xa')](config[_0xbf70('0xb')],{'host':'localhost','port':0x18eb});var socket=require(_0xbf70('0xc'))(new Redis(config[_0xbf70('0xb')]));require(_0xbf70('0xd'))[_0xbf70('0xe')](socket);function respondWithRpcPromise(_0x877a5b,_0x319854,_0x56ca5c){return new BPromise(function(_0x36913f,_0xfc711c){return client[_0xbf70('0xf')](_0x877a5b,_0x56ca5c)[_0xbf70('0x10')](function(_0x1bbaed){logger[_0xbf70('0x11')](_0xbf70('0x12'),_0x319854,_0xbf70('0x13'));logger[_0xbf70('0x14')](_0xbf70('0x15'),_0x319854,'request\x20sent',JSON[_0xbf70('0x16')](_0x1bbaed));if(_0x1bbaed[_0xbf70('0x17')]){if(_0x1bbaed['error']['code']===0x1f4){logger[_0xbf70('0x17')](_0xbf70('0x12'),_0x319854,_0x1bbaed['error']['message']);return _0xfc711c(_0x1bbaed[_0xbf70('0x17')][_0xbf70('0x18')]);}logger['error'](_0xbf70('0x12'),_0x319854,_0x1bbaed[_0xbf70('0x17')][_0xbf70('0x18')]);return _0x36913f(_0x1bbaed['error'][_0xbf70('0x18')]);}else{logger[_0xbf70('0x11')](_0xbf70('0x12'),_0x319854,_0xbf70('0x13'));_0x36913f(_0x1bbaed[_0xbf70('0x19')]['message']);}})[_0xbf70('0x1a')](function(_0x547b25){logger[_0xbf70('0x17')](_0xbf70('0x12'),_0x319854,_0x547b25);_0xfc711c(_0x547b25);});});}exports[_0xbf70('0x1b')]=function(_0x2ac7c8){var _0x265523=this;return new Promise(function(_0x29376d,_0x363027){return db[_0xbf70('0x1c')][_0xbf70('0x1d')](_0x2ac7c8[_0xbf70('0x1e')],{'raw':_0x2ac7c8[_0xbf70('0x1f')]?_0x2ac7c8['options'][_0xbf70('0x20')]===undefined?!![]:![]:!![]})[_0xbf70('0x10')](function(_0x3470cc){logger[_0xbf70('0x11')](_0xbf70('0x1b'),_0x2ac7c8);logger[_0xbf70('0x14')](_0xbf70('0x1b'),_0x2ac7c8,JSON[_0xbf70('0x16')](_0x3470cc));_0x29376d(_0x3470cc);})[_0xbf70('0x1a')](function(_0x44ca2b){logger[_0xbf70('0x17')]('CreateChatMessage',_0x44ca2b[_0xbf70('0x18')],_0x2ac7c8);_0x363027(_0x265523[_0xbf70('0x17')](0x1f4,_0x44ca2b[_0xbf70('0x18')]));});});};