Built motion from commit (unavailable).|2.5.17
[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 _0x670c=['redis','defaults','socket.io-emitter','./chatMessage.socket','register','request','then','info','ChatMessage,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','CreateChatMessage','ChatMessage','create','body','debug','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http'];(function(_0x464127,_0x4a0cfe){var _0x3e01a3=function(_0x2007e8){while(--_0x2007e8){_0x464127['push'](_0x464127['shift']());}};_0x3e01a3(++_0x4a0cfe);}(_0x670c,0x13e));var _0xc670=function(_0x37c13c,_0x5305ac){_0x37c13c=_0x37c13c-0x0;var _0x12cb99=_0x670c[_0x37c13c];return _0x12cb99;};'use strict';var _=require(_0xc670('0x0'));var util=require(_0xc670('0x1'));var moment=require(_0xc670('0x2'));var BPromise=require(_0xc670('0x3'));var rs=require(_0xc670('0x4'));var fs=require('fs');var Redis=require(_0xc670('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xc670('0x6'));var logger=require(_0xc670('0x7'))(_0xc670('0x8'));var config=require(_0xc670('0x9'));var jayson=require(_0xc670('0xa'));var client=jayson['client'][_0xc670('0xb')]({'port':0x232a});config[_0xc670('0xc')]=_[_0xc670('0xd')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0xc670('0xe'))(new Redis(config[_0xc670('0xc')]));require(_0xc670('0xf'))[_0xc670('0x10')](socket);function respondWithRpcPromise(_0x2631e3,_0x24009f,_0x19bc2a){return new BPromise(function(_0x46d8f0,_0x45d449){return client[_0xc670('0x11')](_0x2631e3,_0x19bc2a)[_0xc670('0x12')](function(_0x11c48c){logger[_0xc670('0x13')](_0xc670('0x14'),_0x24009f,_0xc670('0x15'));logger['debug']('ChatMessage,\x20%s,\x20%s,\x20%s',_0x24009f,_0xc670('0x15'),JSON[_0xc670('0x16')](_0x11c48c));if(_0x11c48c[_0xc670('0x17')]){if(_0x11c48c[_0xc670('0x17')][_0xc670('0x18')]===0x1f4){logger['error']('ChatMessage,\x20%s,\x20%s',_0x24009f,_0x11c48c[_0xc670('0x17')][_0xc670('0x19')]);return _0x45d449(_0x11c48c[_0xc670('0x17')][_0xc670('0x19')]);}logger[_0xc670('0x17')](_0xc670('0x14'),_0x24009f,_0x11c48c['error'][_0xc670('0x19')]);return _0x46d8f0(_0x11c48c['error'][_0xc670('0x19')]);}else{logger[_0xc670('0x13')](_0xc670('0x14'),_0x24009f,_0xc670('0x15'));_0x46d8f0(_0x11c48c[_0xc670('0x1a')]['message']);}})[_0xc670('0x1b')](function(_0x4abad7){logger[_0xc670('0x17')](_0xc670('0x14'),_0x24009f,_0x4abad7);_0x45d449(_0x4abad7);});});}exports[_0xc670('0x1c')]=function(_0x9b589d){var _0x2cc114=this;return new Promise(function(_0x487bf1,_0x5a16cd){return db[_0xc670('0x1d')][_0xc670('0x1e')](_0x9b589d[_0xc670('0x1f')],{'raw':_0x9b589d['options']?_0x9b589d['options']['raw']===undefined?!![]:![]:!![]})[_0xc670('0x12')](function(_0x16e480){logger[_0xc670('0x13')](_0xc670('0x1c'),_0x9b589d);logger[_0xc670('0x20')](_0xc670('0x1c'),_0x9b589d,JSON['stringify'](_0x16e480));_0x487bf1(_0x16e480);})[_0xc670('0x1b')](function(_0x131b69){logger[_0xc670('0x17')]('CreateChatMessage',_0x131b69[_0xc670('0x19')],_0x9b589d);_0x5a16cd(_0x2cc114[_0xc670('0x17')](0x1f4,_0x131b69[_0xc670('0x19')]));});});};