quickly fix embed redirecting

This commit is contained in:
Sean Yesmunt 2020-12-22 21:37:55 -05:00
parent f2d00f2ad9
commit f93a40aa18

View file

@ -155,7 +155,7 @@ function buildClaimOgMetadata(uri, claim, overrideOptions = {}) {
return head; return head;
} }
async function getClaimFromChainqueryOrRedirect(ctx, url) { async function getClaimFromChainqueryOrRedirect(ctx, url, ignoreRedirect = false) {
const { isChannel, streamName, channelName, channelClaimId, streamClaimId } = parseURI(url); const { isChannel, streamName, channelName, channelClaimId, streamClaimId } = parseURI(url);
const claimName = isChannel ? '@' + channelName : streamName; const claimName = isChannel ? '@' + channelName : streamName;
const claimId = isChannel ? channelClaimId : streamClaimId; const claimId = isChannel ? channelClaimId : streamClaimId;
@ -164,7 +164,7 @@ async function getClaimFromChainqueryOrRedirect(ctx, url) {
if (rows && rows.length) { if (rows && rows.length) {
const claim = rows[0]; const claim = rows[0];
if (claim.reposted_name && claim.reposted_claim_id) { if (claim.reposted_name && claim.reposted_claim_id && !ignoreRedirect) {
ctx.redirect(`/${claim.reposted_name}:${claim.reposted_claim_id}`); ctx.redirect(`/${claim.reposted_name}:${claim.reposted_claim_id}`);
return; return;
} }
@ -216,7 +216,7 @@ async function getHtml(ctx) {
if (requestPath.includes(embedPath)) { if (requestPath.includes(embedPath)) {
const claimUri = requestPath.replace(embedPath, '').replace(/:/g, '#'); const claimUri = requestPath.replace(embedPath, '').replace(/:/g, '#');
const claim = await getClaimFromChainqueryOrRedirect(ctx, claimUri); const claim = await getClaimFromChainqueryOrRedirect(ctx, claimUri, true);
if (claim) { if (claim) {
const ogMetadata = buildClaimOgMetadata(claimUri, claim); const ogMetadata = buildClaimOgMetadata(claimUri, claim);