Built motion from commit 936e8062.|2.5.33
[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 _0xfcf2=['util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','./whatsappMessage.socket','register','request','then','info','WhatsappMessage,\x20%s,\x20%s','request\x20sent','debug','error','code','message','CreateWhatsappMessage','body','options','raw','stringify','catch','lodash'];(function(_0xbe2a67,_0x20404e){var _0x2c9240=function(_0x56fe5a){while(--_0x56fe5a){_0xbe2a67['push'](_0xbe2a67['shift']());}};_0x2c9240(++_0x20404e);}(_0xfcf2,0x19f));var _0x2fcf=function(_0x40220a,_0x22feb1){_0x40220a=_0x40220a-0x0;var _0x3903cc=_0xfcf2[_0x40220a];return _0x3903cc;};'use strict';var _=require(_0x2fcf('0x0'));var util=require(_0x2fcf('0x1'));var moment=require(_0x2fcf('0x2'));var BPromise=require('bluebird');var rs=require(_0x2fcf('0x3'));var fs=require('fs');var Redis=require(_0x2fcf('0x4'));var db=require(_0x2fcf('0x5'))['db'];var utils=require(_0x2fcf('0x6'));var logger=require(_0x2fcf('0x7'))('rpc');var config=require(_0x2fcf('0x8'));var jayson=require(_0x2fcf('0x9'));var client=jayson[_0x2fcf('0xa')][_0x2fcf('0xb')]({'port':0x232a});config[_0x2fcf('0xc')]=_[_0x2fcf('0xd')](config['redis'],{'host':_0x2fcf('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x2fcf('0xc')]));require(_0x2fcf('0xf'))[_0x2fcf('0x10')](socket);function respondWithRpcPromise(_0x1c038d,_0x1cd90a,_0x44f6d8){return new BPromise(function(_0x4dd588,_0x2a3996){return client[_0x2fcf('0x11')](_0x1c038d,_0x44f6d8)[_0x2fcf('0x12')](function(_0xcc468c){logger[_0x2fcf('0x13')](_0x2fcf('0x14'),_0x1cd90a,_0x2fcf('0x15'));logger[_0x2fcf('0x16')]('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x1cd90a,'request\x20sent',JSON['stringify'](_0xcc468c));if(_0xcc468c[_0x2fcf('0x17')]){if(_0xcc468c[_0x2fcf('0x17')][_0x2fcf('0x18')]===0x1f4){logger[_0x2fcf('0x17')]('WhatsappMessage,\x20%s,\x20%s',_0x1cd90a,_0xcc468c['error'][_0x2fcf('0x19')]);return _0x2a3996(_0xcc468c[_0x2fcf('0x17')][_0x2fcf('0x19')]);}logger[_0x2fcf('0x17')](_0x2fcf('0x14'),_0x1cd90a,_0xcc468c[_0x2fcf('0x17')][_0x2fcf('0x19')]);return _0x4dd588(_0xcc468c[_0x2fcf('0x17')][_0x2fcf('0x19')]);}else{logger[_0x2fcf('0x13')]('WhatsappMessage,\x20%s,\x20%s',_0x1cd90a,_0x2fcf('0x15'));_0x4dd588(_0xcc468c['result'][_0x2fcf('0x19')]);}})['catch'](function(_0x85df79){logger[_0x2fcf('0x17')]('WhatsappMessage,\x20%s,\x20%s',_0x1cd90a,_0x85df79);_0x2a3996(_0x85df79);});});}exports[_0x2fcf('0x1a')]=function(_0x4e7ce0){var _0x4812bc=this;return new Promise(function(_0x4e9217,_0x4e94aa){return db['WhatsappMessage']['create'](_0x4e7ce0[_0x2fcf('0x1b')],{'raw':_0x4e7ce0[_0x2fcf('0x1c')]?_0x4e7ce0[_0x2fcf('0x1c')][_0x2fcf('0x1d')]===undefined?!![]:![]:!![]})[_0x2fcf('0x12')](function(_0x41a843){logger[_0x2fcf('0x13')](_0x2fcf('0x1a'),_0x4e7ce0);logger['debug'](_0x2fcf('0x1a'),_0x4e7ce0,JSON[_0x2fcf('0x1e')](_0x41a843));_0x4e9217(_0x41a843);})[_0x2fcf('0x1f')](function(_0x5e1d6f){logger['error'](_0x2fcf('0x1a'),_0x5e1d6f['message'],_0x4e7ce0);_0x4e94aa(_0x4812bc[_0x2fcf('0x17')](0x1f4,_0x5e1d6f['message']));});});};