e8df5105827866b9adcf9b2d7223f45fa2452bdb
[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 _0x4b4c=['../../config/environment','client','redis','localhost','./whatsappMessage.socket','register','request','then','WhatsappMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','info','result','catch','CreateWhatsappMessage','WhatsappMessage','create','body','options','raw','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc'];(function(_0x25e7cb,_0x3579b7){var _0x375d92=function(_0xe8cf3b){while(--_0xe8cf3b){_0x25e7cb['push'](_0x25e7cb['shift']());}};_0x375d92(++_0x3579b7);}(_0x4b4c,0x162));var _0xc4b4=function(_0x191485,_0x18a5ec){_0x191485=_0x191485-0x0;var _0x4e9c7a=_0x4b4c[_0x191485];return _0x4e9c7a;};'use strict';var _=require(_0xc4b4('0x0'));var util=require(_0xc4b4('0x1'));var moment=require(_0xc4b4('0x2'));var BPromise=require(_0xc4b4('0x3'));var rs=require(_0xc4b4('0x4'));var fs=require('fs');var Redis=require(_0xc4b4('0x5'));var db=require(_0xc4b4('0x6'))['db'];var utils=require(_0xc4b4('0x7'));var logger=require('../../config/logger')(_0xc4b4('0x8'));var config=require(_0xc4b4('0x9'));var jayson=require('jayson/promise');var client=jayson[_0xc4b4('0xa')]['http']({'port':0x232a});config['redis']=_['defaults'](config[_0xc4b4('0xb')],{'host':_0xc4b4('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xc4b4('0xb')]));require(_0xc4b4('0xd'))[_0xc4b4('0xe')](socket);function respondWithRpcPromise(_0x29a01d,_0x4fee90,_0x13b8ce){return new BPromise(function(_0x14ade0,_0x6714cf){return client[_0xc4b4('0xf')](_0x29a01d,_0x13b8ce)[_0xc4b4('0x10')](function(_0x80499e){logger['info'](_0xc4b4('0x11'),_0x4fee90,_0xc4b4('0x12'));logger[_0xc4b4('0x13')]('WhatsappMessage,\x20%s,\x20%s,\x20%s',_0x4fee90,_0xc4b4('0x12'),JSON[_0xc4b4('0x14')](_0x80499e));if(_0x80499e['error']){if(_0x80499e[_0xc4b4('0x15')][_0xc4b4('0x16')]===0x1f4){logger[_0xc4b4('0x15')](_0xc4b4('0x11'),_0x4fee90,_0x80499e[_0xc4b4('0x15')]['message']);return _0x6714cf(_0x80499e[_0xc4b4('0x15')][_0xc4b4('0x17')]);}logger[_0xc4b4('0x15')](_0xc4b4('0x11'),_0x4fee90,_0x80499e['error'][_0xc4b4('0x17')]);return _0x14ade0(_0x80499e[_0xc4b4('0x15')]['message']);}else{logger[_0xc4b4('0x18')](_0xc4b4('0x11'),_0x4fee90,_0xc4b4('0x12'));_0x14ade0(_0x80499e[_0xc4b4('0x19')][_0xc4b4('0x17')]);}})[_0xc4b4('0x1a')](function(_0x2b8c0a){logger[_0xc4b4('0x15')]('WhatsappMessage,\x20%s,\x20%s',_0x4fee90,_0x2b8c0a);_0x6714cf(_0x2b8c0a);});});}exports[_0xc4b4('0x1b')]=function(_0x514234){var _0x47be6a=this;return new Promise(function(_0x15ec3c,_0x6576b0){return db[_0xc4b4('0x1c')][_0xc4b4('0x1d')](_0x514234[_0xc4b4('0x1e')],{'raw':_0x514234[_0xc4b4('0x1f')]?_0x514234[_0xc4b4('0x1f')][_0xc4b4('0x20')]===undefined?!![]:![]:!![]})[_0xc4b4('0x10')](function(_0x162305){logger[_0xc4b4('0x18')](_0xc4b4('0x1b'),_0x514234);logger['debug']('CreateWhatsappMessage',_0x514234,JSON['stringify'](_0x162305));_0x15ec3c(_0x162305);})[_0xc4b4('0x1a')](function(_0x4be294){logger[_0xc4b4('0x15')]('CreateWhatsappMessage',_0x4be294['message'],_0x514234);_0x6576b0(_0x47be6a[_0xc4b4('0x15')](0x1f4,_0x4be294[_0xc4b4('0x17')]));});});};