Built motion from commit (unavailable).|2.5.7
[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 _0xa226=['result','catch','create','body','options','raw','CreateWhatsappMessage','lodash','moment','bluebird','randomstring','rpc','jayson/promise','client','http','redis','localhost','socket.io-emitter','./whatsappMessage.socket','register','request','then','info','WhatsappMessage,\x20%s,\x20%s','request\x20sent','debug','WhatsappMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message'];(function(_0x446ce5,_0x515b58){var _0x43b6e0=function(_0x4da954){while(--_0x4da954){_0x446ce5['push'](_0x446ce5['shift']());}};_0x43b6e0(++_0x515b58);}(_0xa226,0xff));var _0x6a22=function(_0x36a14e,_0x42ba2f){_0x36a14e=_0x36a14e-0x0;var _0x8b6697=_0xa226[_0x36a14e];return _0x8b6697;};'use strict';var _=require(_0x6a22('0x0'));var util=require('util');var moment=require(_0x6a22('0x1'));var BPromise=require(_0x6a22('0x2'));var rs=require(_0x6a22('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x6a22('0x4'));var config=require('../../config/environment');var jayson=require(_0x6a22('0x5'));var client=jayson[_0x6a22('0x6')][_0x6a22('0x7')]({'port':0x232a});config[_0x6a22('0x8')]=_['defaults'](config[_0x6a22('0x8')],{'host':_0x6a22('0x9'),'port':0x18eb});var socket=require(_0x6a22('0xa'))(new Redis(config['redis']));require(_0x6a22('0xb'))[_0x6a22('0xc')](socket);function respondWithRpcPromise(_0x40cef6,_0x434a58,_0x18a38c){return new BPromise(function(_0xd1f37a,_0x3ef342){return client[_0x6a22('0xd')](_0x40cef6,_0x18a38c)[_0x6a22('0xe')](function(_0x3f2004){logger[_0x6a22('0xf')](_0x6a22('0x10'),_0x434a58,_0x6a22('0x11'));logger[_0x6a22('0x12')](_0x6a22('0x13'),_0x434a58,_0x6a22('0x11'),JSON[_0x6a22('0x14')](_0x3f2004));if(_0x3f2004[_0x6a22('0x15')]){if(_0x3f2004[_0x6a22('0x15')][_0x6a22('0x16')]===0x1f4){logger[_0x6a22('0x15')]('WhatsappMessage,\x20%s,\x20%s',_0x434a58,_0x3f2004[_0x6a22('0x15')][_0x6a22('0x17')]);return _0x3ef342(_0x3f2004[_0x6a22('0x15')]['message']);}logger[_0x6a22('0x15')]('WhatsappMessage,\x20%s,\x20%s',_0x434a58,_0x3f2004['error'][_0x6a22('0x17')]);return _0xd1f37a(_0x3f2004[_0x6a22('0x15')][_0x6a22('0x17')]);}else{logger[_0x6a22('0xf')]('WhatsappMessage,\x20%s,\x20%s',_0x434a58,'request\x20sent');_0xd1f37a(_0x3f2004[_0x6a22('0x18')][_0x6a22('0x17')]);}})[_0x6a22('0x19')](function(_0x1d262d){logger[_0x6a22('0x15')](_0x6a22('0x10'),_0x434a58,_0x1d262d);_0x3ef342(_0x1d262d);});});}exports['CreateWhatsappMessage']=function(_0x2277d9){var _0x53fe6b=this;return new Promise(function(_0x2585f2,_0x25d936){return db['WhatsappMessage'][_0x6a22('0x1a')](_0x2277d9[_0x6a22('0x1b')],{'raw':_0x2277d9[_0x6a22('0x1c')]?_0x2277d9[_0x6a22('0x1c')][_0x6a22('0x1d')]===undefined?!![]:![]:!![]})[_0x6a22('0xe')](function(_0x1d8616){logger[_0x6a22('0xf')](_0x6a22('0x1e'),_0x2277d9);logger[_0x6a22('0x12')]('CreateWhatsappMessage',_0x2277d9,JSON[_0x6a22('0x14')](_0x1d8616));_0x2585f2(_0x1d8616);})['catch'](function(_0x46d3ce){logger['error'](_0x6a22('0x1e'),_0x46d3ce[_0x6a22('0x17')],_0x2277d9);_0x25d936(_0x53fe6b['error'](0x1f4,_0x46d3ce['message']));});});};