Built motion from commit 85328c08.|2.5.50
[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 _0x28f9=['moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','redis','defaults','localhost','socket.io-emitter','./chatMessage.socket','register','request','then','info','request\x20sent','debug','ChatMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','ChatMessage,\x20%s,\x20%s','catch','CreateChatMessage','ChatMessage','create','body','options','raw','lodash','util'];(function(_0x43371b,_0x1cb4cf){var _0x19cd26=function(_0x5f43bf){while(--_0x5f43bf){_0x43371b['push'](_0x43371b['shift']());}};_0x19cd26(++_0x1cb4cf);}(_0x28f9,0x174));var _0x928f=function(_0x13e655,_0x14669a){_0x13e655=_0x13e655-0x0;var _0xb47447=_0x28f9[_0x13e655];return _0xb47447;};'use strict';var _=require(_0x928f('0x0'));var util=require(_0x928f('0x1'));var moment=require(_0x928f('0x2'));var BPromise=require(_0x928f('0x3'));var rs=require(_0x928f('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x928f('0x5'));var logger=require(_0x928f('0x6'))(_0x928f('0x7'));var config=require(_0x928f('0x8'));var jayson=require(_0x928f('0x9'));var client=jayson['client']['http']({'port':0x232a});config[_0x928f('0xa')]=_[_0x928f('0xb')](config['redis'],{'host':_0x928f('0xc'),'port':0x18eb});var socket=require(_0x928f('0xd'))(new Redis(config[_0x928f('0xa')]));require(_0x928f('0xe'))[_0x928f('0xf')](socket);function respondWithRpcPromise(_0x34481f,_0xa862b2,_0x3b92f6){return new BPromise(function(_0xaee291,_0x1d4d24){return client[_0x928f('0x10')](_0x34481f,_0x3b92f6)[_0x928f('0x11')](function(_0x4bbddd){logger[_0x928f('0x12')]('ChatMessage,\x20%s,\x20%s',_0xa862b2,_0x928f('0x13'));logger[_0x928f('0x14')](_0x928f('0x15'),_0xa862b2,_0x928f('0x13'),JSON[_0x928f('0x16')](_0x4bbddd));if(_0x4bbddd[_0x928f('0x17')]){if(_0x4bbddd['error'][_0x928f('0x18')]===0x1f4){logger[_0x928f('0x17')]('ChatMessage,\x20%s,\x20%s',_0xa862b2,_0x4bbddd[_0x928f('0x17')][_0x928f('0x19')]);return _0x1d4d24(_0x4bbddd[_0x928f('0x17')][_0x928f('0x19')]);}logger[_0x928f('0x17')](_0x928f('0x1a'),_0xa862b2,_0x4bbddd[_0x928f('0x17')][_0x928f('0x19')]);return _0xaee291(_0x4bbddd[_0x928f('0x17')][_0x928f('0x19')]);}else{logger[_0x928f('0x12')](_0x928f('0x1a'),_0xa862b2,_0x928f('0x13'));_0xaee291(_0x4bbddd['result'][_0x928f('0x19')]);}})[_0x928f('0x1b')](function(_0x1b92ed){logger[_0x928f('0x17')](_0x928f('0x1a'),_0xa862b2,_0x1b92ed);_0x1d4d24(_0x1b92ed);});});}exports[_0x928f('0x1c')]=function(_0x1eb22e){var _0x485caf=this;return new Promise(function(_0xe946c,_0xd630a2){return db[_0x928f('0x1d')][_0x928f('0x1e')](_0x1eb22e[_0x928f('0x1f')],{'raw':_0x1eb22e['options']?_0x1eb22e[_0x928f('0x20')][_0x928f('0x21')]===undefined?!![]:![]:!![]})[_0x928f('0x11')](function(_0x2e5b25){logger[_0x928f('0x12')](_0x928f('0x1c'),_0x1eb22e);logger[_0x928f('0x14')](_0x928f('0x1c'),_0x1eb22e,JSON[_0x928f('0x16')](_0x2e5b25));_0xe946c(_0x2e5b25);})['catch'](function(_0xfee195){logger[_0x928f('0x17')]('CreateChatMessage',_0xfee195['message'],_0x1eb22e);_0xd630a2(_0x485caf[_0x928f('0x17')](0x1f4,_0xfee195[_0x928f('0x19')]));});});};