initial fix for #3723

This commit is contained in:
Sean Yesmunt 2020-04-08 14:49:37 -04:00
parent 74c4762cd4
commit d94610acb1
3 changed files with 6 additions and 7 deletions

View file

@ -24,7 +24,7 @@ module.exports.getClaim = async function getClaim(claimName, claimId, channelNam
let params = [claimName];
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 ' +
'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 ' +
'FROM claim ' +
'LEFT JOIN claim channel_claim on claim.publisher_id = channel_claim.claim_id ' +
'WHERE claim.name = ?';

View file

@ -63,12 +63,11 @@ function buildClaimOgMetadata(uri, claim, overrideOptions = {}) {
? escapeHtmlProperty(truncateDescription(claim.description))
: `View ${claimTitle} on lbry.tv`;
const claimLanguage = escapeHtmlProperty(claim.language) || 'en_US';
const isImage = claim && claim.value && claim.value.stream_type === 'image';
const isFree = claim && claim.value && (!claim.value.fee || Number(claim.value.fee.amount) <= 0);
let imageThumbnail;
if (claim && isImage && isFree) {
imageThumbnail = generateStreamUrl(claimName, claim.claim_id);
if (Number(claim.fee) <= 0 && claim.source_media_type.startsWith('image/')) {
imageThumbnail = generateStreamUrl(claim.name, claim.claim_id, undefined, undefined, true);
}
const claimThumbnail = escapeHtmlProperty(claim.thumbnail_url) || imageThumbnail || `${URL}/v1-og.png`;

View file

@ -3,9 +3,9 @@ const { getCookie } = require('../../ui/util/saved-passwords');
const CONTINENT_COOKIE = 'continent';
function generateStreamUrl(claimName, claimId, apiUrl, streamingContinent) {
function generateStreamUrl(claimName, claimId, apiUrl, streamingContinent, useDefaultServer) {
let prefix = LBRY_TV_STREAMING_API || apiUrl;
const continent = streamingContinent || getCookie(CONTINENT_COOKIE);
const continent = useDefaultServer ? undefined : streamingContinent || getCookie(CONTINENT_COOKIE);
if (continent && prefix.split('//').length > 1) {
prefix = prefix.replace('//', '//' + continent + '.');