Built motion from commit (unavailable).|2.5.2
[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 _0xf8f8=['error','message','result','catch','CreateChatMessage','ChatMessage','create','body','options','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','http','defaults','redis','./chatMessage.socket','register','request','then','info','ChatMessage,\x20%s,\x20%s','debug','ChatMessage,\x20%s,\x20%s,\x20%s'];(function(_0x7f8053,_0x4f2b75){var _0x77324e=function(_0x5260fc){while(--_0x5260fc){_0x7f8053['push'](_0x7f8053['shift']());}};_0x77324e(++_0x4f2b75);}(_0xf8f8,0x1d9));var _0x8f8f=function(_0x454963,_0x2405b2){_0x454963=_0x454963-0x0;var _0x1e49a8=_0xf8f8[_0x454963];return _0x1e49a8;};'use strict';var _=require(_0x8f8f('0x0'));var util=require(_0x8f8f('0x1'));var moment=require(_0x8f8f('0x2'));var BPromise=require('bluebird');var rs=require(_0x8f8f('0x3'));var fs=require('fs');var Redis=require(_0x8f8f('0x4'));var db=require(_0x8f8f('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x8f8f('0x6'))('rpc');var config=require(_0x8f8f('0x7'));var jayson=require(_0x8f8f('0x8'));var client=jayson['client'][_0x8f8f('0x9')]({'port':0x232a});config['redis']=_[_0x8f8f('0xa')](config[_0x8f8f('0xb')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x8f8f('0xb')]));require(_0x8f8f('0xc'))[_0x8f8f('0xd')](socket);function respondWithRpcPromise(_0x1e666c,_0x28a4bf,_0x1795f4){return new BPromise(function(_0x280441,_0x51b1c2){return client[_0x8f8f('0xe')](_0x1e666c,_0x1795f4)[_0x8f8f('0xf')](function(_0x30754b){logger[_0x8f8f('0x10')](_0x8f8f('0x11'),_0x28a4bf,'request\x20sent');logger[_0x8f8f('0x12')](_0x8f8f('0x13'),_0x28a4bf,'request\x20sent',JSON['stringify'](_0x30754b));if(_0x30754b[_0x8f8f('0x14')]){if(_0x30754b[_0x8f8f('0x14')]['code']===0x1f4){logger[_0x8f8f('0x14')](_0x8f8f('0x11'),_0x28a4bf,_0x30754b[_0x8f8f('0x14')]['message']);return _0x51b1c2(_0x30754b[_0x8f8f('0x14')]['message']);}logger[_0x8f8f('0x14')](_0x8f8f('0x11'),_0x28a4bf,_0x30754b['error'][_0x8f8f('0x15')]);return _0x280441(_0x30754b[_0x8f8f('0x14')][_0x8f8f('0x15')]);}else{logger[_0x8f8f('0x10')](_0x8f8f('0x11'),_0x28a4bf,'request\x20sent');_0x280441(_0x30754b[_0x8f8f('0x16')]['message']);}})[_0x8f8f('0x17')](function(_0x4760fb){logger[_0x8f8f('0x14')](_0x8f8f('0x11'),_0x28a4bf,_0x4760fb);_0x51b1c2(_0x4760fb);});});}exports[_0x8f8f('0x18')]=function(_0x596960){var _0x5ed7ca=this;return new Promise(function(_0x158939,_0x1706b9){return db[_0x8f8f('0x19')][_0x8f8f('0x1a')](_0x596960[_0x8f8f('0x1b')],{'raw':_0x596960[_0x8f8f('0x1c')]?_0x596960[_0x8f8f('0x1c')]['raw']===undefined?!![]:![]:!![]})[_0x8f8f('0xf')](function(_0x3f63e2){logger[_0x8f8f('0x10')](_0x8f8f('0x18'),_0x596960);logger[_0x8f8f('0x12')](_0x8f8f('0x18'),_0x596960,JSON['stringify'](_0x3f63e2));_0x158939(_0x3f63e2);})[_0x8f8f('0x17')](function(_0x19b78d){logger[_0x8f8f('0x14')]('CreateChatMessage',_0x19b78d[_0x8f8f('0x15')],_0x596960);_0x1706b9(_0x5ed7ca[_0x8f8f('0x14')](0x1f4,_0x19b78d['message']));});});};