Built motion from commit fe909640.|2.6.8
[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 _0x76ca=['debug','WhatsappMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','CreateWhatsappMessage','WhatsappMessage','options','raw','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','jayson/promise','client','redis','localhost','socket.io-emitter','request','then','info','WhatsappMessage,\x20%s,\x20%s','request\x20sent'];(function(_0x44216d,_0x4938a7){var _0xeca523=function(_0x11faf1){while(--_0x11faf1){_0x44216d['push'](_0x44216d['shift']());}};_0xeca523(++_0x4938a7);}(_0x76ca,0x173));var _0xa76c=function(_0x125cb5,_0x457cc3){_0x125cb5=_0x125cb5-0x0;var _0x4f8898=_0x76ca[_0x125cb5];return _0x4f8898;};'use strict';var _=require(_0xa76c('0x0'));var util=require(_0xa76c('0x1'));var moment=require(_0xa76c('0x2'));var BPromise=require(_0xa76c('0x3'));var rs=require(_0xa76c('0x4'));var fs=require('fs');var Redis=require(_0xa76c('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xa76c('0x6'));var logger=require(_0xa76c('0x7'))(_0xa76c('0x8'));var config=require('../../config/environment');var jayson=require(_0xa76c('0x9'));var client=jayson[_0xa76c('0xa')]['http']({'port':0x232a});config['redis']=_['defaults'](config[_0xa76c('0xb')],{'host':_0xa76c('0xc'),'port':0x18eb});var socket=require(_0xa76c('0xd'))(new Redis(config[_0xa76c('0xb')]));require('./whatsappMessage.socket')['register'](socket);function respondWithRpcPromise(_0x45c90a,_0x5be753,_0xb9a286){return new BPromise(function(_0x3b9960,_0x3cb94c){return client[_0xa76c('0xe')](_0x45c90a,_0xb9a286)[_0xa76c('0xf')](function(_0x49981b){logger[_0xa76c('0x10')](_0xa76c('0x11'),_0x5be753,_0xa76c('0x12'));logger[_0xa76c('0x13')](_0xa76c('0x14'),_0x5be753,'request\x20sent',JSON[_0xa76c('0x15')](_0x49981b));if(_0x49981b[_0xa76c('0x16')]){if(_0x49981b['error'][_0xa76c('0x17')]===0x1f4){logger[_0xa76c('0x16')]('WhatsappMessage,\x20%s,\x20%s',_0x5be753,_0x49981b[_0xa76c('0x16')][_0xa76c('0x18')]);return _0x3cb94c(_0x49981b[_0xa76c('0x16')][_0xa76c('0x18')]);}logger[_0xa76c('0x16')](_0xa76c('0x11'),_0x5be753,_0x49981b[_0xa76c('0x16')][_0xa76c('0x18')]);return _0x3b9960(_0x49981b[_0xa76c('0x16')]['message']);}else{logger[_0xa76c('0x10')](_0xa76c('0x11'),_0x5be753,_0xa76c('0x12'));_0x3b9960(_0x49981b[_0xa76c('0x19')][_0xa76c('0x18')]);}})['catch'](function(_0x4177f1){logger[_0xa76c('0x16')]('WhatsappMessage,\x20%s,\x20%s',_0x5be753,_0x4177f1);_0x3cb94c(_0x4177f1);});});}exports[_0xa76c('0x1a')]=function(_0x2d4508){var _0x38b5a5=this;return new Promise(function(_0x4943fd,_0x251917){return db[_0xa76c('0x1b')]['create'](_0x2d4508['body'],{'raw':_0x2d4508[_0xa76c('0x1c')]?_0x2d4508[_0xa76c('0x1c')][_0xa76c('0x1d')]===undefined?!![]:![]:!![]})[_0xa76c('0xf')](function(_0x5a5a9b){logger[_0xa76c('0x10')](_0xa76c('0x1a'),_0x2d4508);logger['debug'](_0xa76c('0x1a'),_0x2d4508,JSON['stringify'](_0x5a5a9b));_0x4943fd(_0x5a5a9b);})['catch'](function(_0x344455){logger[_0xa76c('0x16')]('CreateWhatsappMessage',_0x344455[_0xa76c('0x18')],_0x2d4508);_0x251917(_0x38b5a5['error'](0x1f4,_0x344455['message']));});});};