update other share option

test
dan 2020-03-29 15:36:52 -06:00
parent d4598d76c0
commit c2d927788a
1 changed files with 10 additions and 7 deletions

View File

@ -25,12 +25,13 @@ router.get("/:shareCode",function(req,res){
case "e": case "e":
return getEvent(req,res,param); return getEvent(req,res,param);
case "o": case "o":
return getOther(req, res) return getOther(req, res, param)
} }
}); });
function getOther(req, res,) { function getOther(req, res, param) {
console.log(req.headers); param = decodeURIComponent(param);
var params = JSON.parse(param);
var userAgent = req.headers['user-agent']; var userAgent = req.headers['user-agent'];
var userAgentOverride = req.headers['user-agent-override']; var userAgentOverride = req.headers['user-agent-override'];
var referrer = req.headers['referer'] || ""; var referrer = req.headers['referer'] || "";
@ -39,9 +40,9 @@ function getOther(req, res,) {
userAgent === 'Facebot' || userAgent === 'Facebot' ||
userAgent.startsWith('Twitterbot') || userAgent.startsWith('Twitterbot') ||
referrer.startsWith('http://opengraphcheck.com')) { referrer.startsWith('http://opengraphcheck.com')) {
getOtherMeta(req, res, req.query.title, req.query.description, req.query.imageUrl, req.query.imageWidth, req.query.imageHeight, req.query.url); getOtherMeta(req, res, params.title, params.description, params.imageUrl, params.imageWidth, params.imageHeight, params.url);
} else { } else {
var url = req.query.url; var url = params.url || (req.protocol + "://" + req.hostname);
res.redirect(url); res.redirect(url);
} }
} }
@ -64,6 +65,8 @@ function getSermon(req, res, id){
} }
function getOtherMeta(req, res, title, description, imageUrl, imageWidth, imageHeight, url) { function getOtherMeta(req, res, title, description, imageUrl, imageWidth, imageHeight, url) {
imageWidth = imageWidth || 200;
imageHeight = imageHeight || 200;
var result = `<html> var result = `<html>
<head> <head>
<title>Old Fashion Baptist Church</title> <title>Old Fashion Baptist Church</title>
@ -74,8 +77,8 @@ function getOtherMeta(req, res, title, description, imageUrl, imageWidth, imageH
<meta property="og:title" content="` + title + `" /> <meta property="og:title" content="` + title + `" />
<meta property="og:description" content="` + description + `" /> <meta property="og:description" content="` + description + `" />
<meta property="og:image" content="` + imageUrl + `" /> <meta property="og:image" content="` + imageUrl + `" />
<meta property="og:image:width" content="`+ imageWidth || '200' +`" /> <meta property="og:image:width" content="`+ imageWidth +`" />
<meta property="og:image:height" content="`+ imageHeight || '200' +`" /> <meta property="og:image:height" content="`+ imageHeight +`" />
</head> </head>
<body> <body>
</body> </body>