Revert "redirect to reposted claims serverside"

This reverts commit c9c98501af.
This commit is contained in:
Sean Yesmunt 2020-07-28 15:14:27 -04:00
parent 43a9393dca
commit 0a60d93c71
2 changed files with 6 additions and 17 deletions

View file

@ -12,7 +12,6 @@ function queryPool(sql, params) {
return new Promise(resolve => { return new Promise(resolve => {
pool.query(sql, params, (error, rows) => { pool.query(sql, params, (error, rows) => {
if (error) { if (error) {
console.log('error', error);
resolve(); resolve();
return; return;
} }
@ -26,13 +25,9 @@ module.exports.getClaim = async function getClaim(claimName, claimId, channelNam
let params = [claimName]; let params = [claimName];
let sql = let sql =
'SELECT channel_claim.name as channel, claim.claim_id, claim.name, claim.description, claim.language, claim.thumbnail_url, claim.title, claim.source_media_type, claim.frame_width, claim.frame_height, claim.fee, ' + 'SELECT channel_claim.name as channel, claim.claim_id, claim.name, claim.description, claim.language, claim.thumbnail_url, claim.title, claim.source_media_type, claim.frame_width, claim.frame_height, claim.fee ' +
'repost_channel.name as repost_channel, reposted_claim.claim_id as reposted_claim_id, reposted_claim.name as reposted_name, reposted_claim.description as reposted_description, reposted_claim.language as reposted_language, reposted_claim.thumbnail_url as reposted_thumbnail_url, reposted_claim.title as reposted_title, reposted_claim.source_media_type as reposted_source_media_type, reposted_claim.frame_width as reposted_frame_width, reposted_claim.frame_height as reposted_frame_height, reposted_claim.fee as reposted_fee ' +
'FROM claim ' + 'FROM claim ' +
'LEFT JOIN claim channel_claim on claim.publisher_id = channel_claim.claim_id ' + 'LEFT JOIN claim channel_claim on claim.publisher_id = channel_claim.claim_id ' +
'LEFT JOIN claim as reposted_claim on reposted_claim.claim_id = claim.claim_reference ' +
'AND (reposted_claim.bid_state="controlling" OR reposted_claim.bid_state="active")' +
'LEFT JOIN claim as repost_channel on repost_channel.claim_id = reposted_claim.publisher_id ' +
'WHERE claim.name = ?'; 'WHERE claim.name = ?';
if (claimId) { if (claimId) {

View file

@ -138,7 +138,7 @@ function buildClaimOgMetadata(uri, claim, overrideOptions = {}) {
return head; return head;
} }
async function getClaimFromChainqueryOrRedirect(url, ctx) { async function getClaimFromChainquery(url) {
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;
@ -146,12 +146,6 @@ async function getClaimFromChainqueryOrRedirect(url, ctx) {
const rows = await getClaim(claimName, claimId, channelName, channelClaimId); const rows = await getClaim(claimName, claimId, channelName, channelClaimId);
if (rows && rows.length) { if (rows && rows.length) {
const claim = rows[0]; const claim = rows[0];
if (claim.reposted_name && claim.reposted_claim_id) {
ctx.redirect(`/${claim.reposted_name}:${claim.reposted_claim_id}`);
return;
}
return claim; return claim;
} }
@ -179,7 +173,7 @@ async function getHtml(ctx) {
try { try {
parseURI(inviteChannelUrl); parseURI(inviteChannelUrl);
const claim = await getClaimFromChainqueryOrRedirect(inviteChannelUrl, ctx); const claim = await getClaimFromChainquery(inviteChannelUrl);
const invitePageMetadata = buildClaimOgMetadata(inviteChannelUrl, claim, { const invitePageMetadata = buildClaimOgMetadata(inviteChannelUrl, claim, {
title: `Join ${claim.name} on LBRY`, title: `Join ${claim.name} on LBRY`,
description: `Join ${claim.name} on LBRY, a content wonderland owned by everyone (and no one).`, description: `Join ${claim.name} on LBRY, a content wonderland owned by everyone (and no one).`,
@ -199,7 +193,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(claimUri, ctx); const claim = await getClaimFromChainquery(claimUri);
if (claim) { if (claim) {
const ogMetadata = buildClaimOgMetadata(claimUri, claim); const ogMetadata = buildClaimOgMetadata(claimUri, claim);
@ -211,8 +205,8 @@ async function getHtml(ctx) {
if (!requestPath.includes('$')) { if (!requestPath.includes('$')) {
const claimUri = requestPath.slice(1).replace(/:/g, '#'); const claimUri = requestPath.slice(1).replace(/:/g, '#');
const claim = await getClaimFromChainqueryOrRedirect(claimUri, ctx); const claim = await getClaimFromChainquery(claimUri);
console.log('claim', claim);
if (claim) { if (claim) {
const ogMetadata = buildClaimOgMetadata(claimUri, claim); const ogMetadata = buildClaimOgMetadata(claimUri, claim);
return insertToHead(html, ogMetadata); return insertToHead(html, ogMetadata);