Built motion from commit 4c579f6b.|2.5.32
[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 _0xcd05=['catch','CreateChatMessage','ChatMessage','create','body','options','raw','lodash','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','redis','defaults','localhost','socket.io-emitter','./chatMessage.socket','request','then','info','ChatMessage,\x20%s,\x20%s','request\x20sent','debug','ChatMessage,\x20%s,\x20%s,\x20%s','stringify','error','message'];(function(_0x1458a6,_0x18de3a){var _0x4b385b=function(_0x56cc35){while(--_0x56cc35){_0x1458a6['push'](_0x1458a6['shift']());}};_0x4b385b(++_0x18de3a);}(_0xcd05,0x163));var _0x5cd0=function(_0x19ac6e,_0x435862){_0x19ac6e=_0x19ac6e-0x0;var _0x1cdcf3=_0xcd05[_0x19ac6e];return _0x1cdcf3;};'use strict';var _=require(_0x5cd0('0x0'));var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x5cd0('0x1'));var fs=require('fs');var Redis=require(_0x5cd0('0x2'));var db=require(_0x5cd0('0x3'))['db'];var utils=require(_0x5cd0('0x4'));var logger=require('../../config/logger')(_0x5cd0('0x5'));var config=require(_0x5cd0('0x6'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});config[_0x5cd0('0x7')]=_[_0x5cd0('0x8')](config[_0x5cd0('0x7')],{'host':_0x5cd0('0x9'),'port':0x18eb});var socket=require(_0x5cd0('0xa'))(new Redis(config[_0x5cd0('0x7')]));require(_0x5cd0('0xb'))['register'](socket);function respondWithRpcPromise(_0xaea974,_0xf5eda1,_0x22f769){return new BPromise(function(_0x368f0c,_0x512903){return client[_0x5cd0('0xc')](_0xaea974,_0x22f769)[_0x5cd0('0xd')](function(_0x447b29){logger[_0x5cd0('0xe')](_0x5cd0('0xf'),_0xf5eda1,_0x5cd0('0x10'));logger[_0x5cd0('0x11')](_0x5cd0('0x12'),_0xf5eda1,_0x5cd0('0x10'),JSON[_0x5cd0('0x13')](_0x447b29));if(_0x447b29['error']){if(_0x447b29['error']['code']===0x1f4){logger[_0x5cd0('0x14')](_0x5cd0('0xf'),_0xf5eda1,_0x447b29['error'][_0x5cd0('0x15')]);return _0x512903(_0x447b29['error'][_0x5cd0('0x15')]);}logger[_0x5cd0('0x14')](_0x5cd0('0xf'),_0xf5eda1,_0x447b29['error']['message']);return _0x368f0c(_0x447b29[_0x5cd0('0x14')][_0x5cd0('0x15')]);}else{logger[_0x5cd0('0xe')]('ChatMessage,\x20%s,\x20%s',_0xf5eda1,'request\x20sent');_0x368f0c(_0x447b29['result'][_0x5cd0('0x15')]);}})[_0x5cd0('0x16')](function(_0x48ede8){logger[_0x5cd0('0x14')](_0x5cd0('0xf'),_0xf5eda1,_0x48ede8);_0x512903(_0x48ede8);});});}exports[_0x5cd0('0x17')]=function(_0x24268d){var _0x2230c1=this;return new Promise(function(_0x2db93c,_0x18b907){return db[_0x5cd0('0x18')][_0x5cd0('0x19')](_0x24268d[_0x5cd0('0x1a')],{'raw':_0x24268d[_0x5cd0('0x1b')]?_0x24268d[_0x5cd0('0x1b')][_0x5cd0('0x1c')]===undefined?!![]:![]:!![]})[_0x5cd0('0xd')](function(_0x5c2bd9){logger['info'](_0x5cd0('0x17'),_0x24268d);logger['debug'](_0x5cd0('0x17'),_0x24268d,JSON[_0x5cd0('0x13')](_0x5c2bd9));_0x2db93c(_0x5c2bd9);})[_0x5cd0('0x16')](function(_0xa3cbb){logger[_0x5cd0('0x14')](_0x5cd0('0x17'),_0xa3cbb[_0x5cd0('0x15')],_0x24268d);_0x18b907(_0x2230c1['error'](0x1f4,_0xa3cbb['message']));});});};