Built motion from commit (unavailable).|2.5.13
[motion2.git] / server / api / whatsappMessage / whatsappMessage.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 _0x68bb=['../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','register','info','debug','WhatsappMessage,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','WhatsappMessage,\x20%s,\x20%s','message','catch','WhatsappMessage','create','body','options','raw','then','CreateWhatsappMessage','lodash','moment','bluebird','randomstring','ioredis'];(function(_0x4915e2,_0x1f80ab){var _0x4cecf2=function(_0x5b8250){while(--_0x5b8250){_0x4915e2['push'](_0x4915e2['shift']());}};_0x4cecf2(++_0x1f80ab);}(_0x68bb,0x83));var _0xb68b=function(_0x46c0cc,_0x283763){_0x46c0cc=_0x46c0cc-0x0;var _0x2bb53a=_0x68bb[_0x46c0cc];return _0x2bb53a;};'use strict';var _=require(_0xb68b('0x0'));var util=require('util');var moment=require(_0xb68b('0x1'));var BPromise=require(_0xb68b('0x2'));var rs=require(_0xb68b('0x3'));var fs=require('fs');var Redis=require(_0xb68b('0x4'));var db=require(_0xb68b('0x5'))['db'];var utils=require(_0xb68b('0x6'));var logger=require(_0xb68b('0x7'))(_0xb68b('0x8'));var config=require('../../config/environment');var jayson=require(_0xb68b('0x9'));var client=jayson[_0xb68b('0xa')][_0xb68b('0xb')]({'port':0x232a});config['redis']=_[_0xb68b('0xc')](config[_0xb68b('0xd')],{'host':_0xb68b('0xe'),'port':0x18eb});var socket=require(_0xb68b('0xf'))(new Redis(config[_0xb68b('0xd')]));require('./whatsappMessage.socket')[_0xb68b('0x10')](socket);function respondWithRpcPromise(_0x38e42f,_0x129b25,_0x30733a){return new BPromise(function(_0x2912a2,_0x2887ac){return client['request'](_0x38e42f,_0x30733a)['then'](function(_0x45273a){logger[_0xb68b('0x11')]('WhatsappMessage,\x20%s,\x20%s',_0x129b25,'request\x20sent');logger[_0xb68b('0x12')](_0xb68b('0x13'),_0x129b25,_0xb68b('0x14'),JSON[_0xb68b('0x15')](_0x45273a));if(_0x45273a['error']){if(_0x45273a[_0xb68b('0x16')][_0xb68b('0x17')]===0x1f4){logger[_0xb68b('0x16')](_0xb68b('0x18'),_0x129b25,_0x45273a[_0xb68b('0x16')][_0xb68b('0x19')]);return _0x2887ac(_0x45273a['error'][_0xb68b('0x19')]);}logger[_0xb68b('0x16')](_0xb68b('0x18'),_0x129b25,_0x45273a[_0xb68b('0x16')][_0xb68b('0x19')]);return _0x2912a2(_0x45273a[_0xb68b('0x16')][_0xb68b('0x19')]);}else{logger[_0xb68b('0x11')]('WhatsappMessage,\x20%s,\x20%s',_0x129b25,_0xb68b('0x14'));_0x2912a2(_0x45273a['result'][_0xb68b('0x19')]);}})[_0xb68b('0x1a')](function(_0x2b0347){logger['error'](_0xb68b('0x18'),_0x129b25,_0x2b0347);_0x2887ac(_0x2b0347);});});}exports['CreateWhatsappMessage']=function(_0x2edfcc){var _0x57bf06=this;return new Promise(function(_0x4ef6dc,_0x1cf3a7){return db[_0xb68b('0x1b')][_0xb68b('0x1c')](_0x2edfcc[_0xb68b('0x1d')],{'raw':_0x2edfcc[_0xb68b('0x1e')]?_0x2edfcc[_0xb68b('0x1e')][_0xb68b('0x1f')]===undefined?!![]:![]:!![]})[_0xb68b('0x20')](function(_0x228eda){logger[_0xb68b('0x11')](_0xb68b('0x21'),_0x2edfcc);logger[_0xb68b('0x12')](_0xb68b('0x21'),_0x2edfcc,JSON[_0xb68b('0x15')](_0x228eda));_0x4ef6dc(_0x228eda);})['catch'](function(_0x4ff238){logger[_0xb68b('0x16')]('CreateWhatsappMessage',_0x4ff238[_0xb68b('0x19')],_0x2edfcc);_0x1cf3a7(_0x57bf06['error'](0x1f4,_0x4ff238[_0xb68b('0x19')]));});});};