Built motion from commit 10af8726.|2.6.34
[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 _0xb495=['info','ChatMessage,\x20%s,\x20%s','request\x20sent','stringify','error','message','catch','CreateChatMessage','create','options','raw','debug','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','redis','defaults','localhost','socket.io-emitter','register','request','then'];(function(_0x56825b,_0x172b8d){var _0x69ce77=function(_0x348a1c){while(--_0x348a1c){_0x56825b['push'](_0x56825b['shift']());}};_0x69ce77(++_0x172b8d);}(_0xb495,0x174));var _0x5b49=function(_0x3d9050,_0x42d036){_0x3d9050=_0x3d9050-0x0;var _0x4875c8=_0xb495[_0x3d9050];return _0x4875c8;};'use strict';var _=require(_0x5b49('0x0'));var util=require(_0x5b49('0x1'));var moment=require(_0x5b49('0x2'));var BPromise=require('bluebird');var rs=require(_0x5b49('0x3'));var fs=require('fs');var Redis=require(_0x5b49('0x4'));var db=require(_0x5b49('0x5'))['db'];var utils=require(_0x5b49('0x6'));var logger=require(_0x5b49('0x7'))(_0x5b49('0x8'));var config=require(_0x5b49('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x5b49('0xa')]['http']({'port':0x232a});config[_0x5b49('0xb')]=_[_0x5b49('0xc')](config[_0x5b49('0xb')],{'host':_0x5b49('0xd'),'port':0x18eb});var socket=require(_0x5b49('0xe'))(new Redis(config['redis']));require('./chatMessage.socket')[_0x5b49('0xf')](socket);function respondWithRpcPromise(_0x504b8a,_0x3c0ab0,_0x1ae0d2){return new BPromise(function(_0x5673af,_0x42642f){return client[_0x5b49('0x10')](_0x504b8a,_0x1ae0d2)[_0x5b49('0x11')](function(_0x3a0f6d){logger[_0x5b49('0x12')](_0x5b49('0x13'),_0x3c0ab0,_0x5b49('0x14'));logger['debug']('ChatMessage,\x20%s,\x20%s,\x20%s',_0x3c0ab0,_0x5b49('0x14'),JSON[_0x5b49('0x15')](_0x3a0f6d));if(_0x3a0f6d['error']){if(_0x3a0f6d['error']['code']===0x1f4){logger[_0x5b49('0x16')](_0x5b49('0x13'),_0x3c0ab0,_0x3a0f6d[_0x5b49('0x16')][_0x5b49('0x17')]);return _0x42642f(_0x3a0f6d['error'][_0x5b49('0x17')]);}logger[_0x5b49('0x16')]('ChatMessage,\x20%s,\x20%s',_0x3c0ab0,_0x3a0f6d['error']['message']);return _0x5673af(_0x3a0f6d[_0x5b49('0x16')][_0x5b49('0x17')]);}else{logger[_0x5b49('0x12')](_0x5b49('0x13'),_0x3c0ab0,_0x5b49('0x14'));_0x5673af(_0x3a0f6d['result'][_0x5b49('0x17')]);}})[_0x5b49('0x18')](function(_0x383b51){logger[_0x5b49('0x16')](_0x5b49('0x13'),_0x3c0ab0,_0x383b51);_0x42642f(_0x383b51);});});}exports[_0x5b49('0x19')]=function(_0x257ae4){var _0xa05082=this;return new Promise(function(_0x28bf56,_0x1a068e){return db['ChatMessage'][_0x5b49('0x1a')](_0x257ae4['body'],{'raw':_0x257ae4[_0x5b49('0x1b')]?_0x257ae4[_0x5b49('0x1b')][_0x5b49('0x1c')]===undefined?!![]:![]:!![]})[_0x5b49('0x11')](function(_0x280919){logger[_0x5b49('0x12')]('CreateChatMessage',_0x257ae4);logger[_0x5b49('0x1d')](_0x5b49('0x19'),_0x257ae4,JSON['stringify'](_0x280919));_0x28bf56(_0x280919);})[_0x5b49('0x18')](function(_0x2a01a4){logger[_0x5b49('0x16')](_0x5b49('0x19'),_0x2a01a4['message'],_0x257ae4);_0x1a068e(_0xa05082['error'](0x1f4,_0x2a01a4[_0x5b49('0x17')]));});});};