Quick-fix, filter views with UA containing LBRY (for thumbs)

This commit is contained in:
Shawn 2018-10-24 17:11:52 -05:00
parent d625d9b76a
commit 828e8dce70
4 changed files with 13 additions and 11 deletions

View file

@ -11,7 +11,7 @@ const serveAsset = ({ headers, ip, originalUrl, params: { claimName, claimId } }
// send google analytics // send google analytics
sendGAServeEvent(headers, ip, originalUrl); sendGAServeEvent(headers, ip, originalUrl);
// get the claim Id and then serve the asset // get the claim Id and then serve the asset
getClaimIdAndServeAsset(null, null, claimName, claimId, originalUrl, ip, res); getClaimIdAndServeAsset(null, null, claimName, claimId, originalUrl, ip, res, headers);
}; };
module.exports = serveAsset; module.exports = serveAsset;

View file

@ -37,7 +37,7 @@ const serveByClaim = (req, res) => {
({ claimName } = lbryUri.parseClaim(params.claim)); ({ claimName } = lbryUri.parseClaim(params.claim));
logger.debug('serve request:', { headers, ip, originalUrl, params }); logger.debug('serve request:', { headers, ip, originalUrl, params });
getClaimIdAndServeAsset(null, null, claimName, null, originalUrl, ip, res); getClaimIdAndServeAsset(null, null, claimName, null, originalUrl, ip, res, headers);
sendGAServeEvent(headers, ip, originalUrl); sendGAServeEvent(headers, ip, originalUrl);
} catch (error) { } catch (error) {

View file

@ -47,7 +47,7 @@ const serverByIdentifierAndClaim = (req, res) => {
claimId, claimId,
}); });
getClaimIdAndServeAsset(channelName, channelClaimId, claimName, claimId, originalUrl, ip, res); getClaimIdAndServeAsset(channelName, channelClaimId, claimName, claimId, originalUrl, ip, res, headers);
sendGAServeEvent(headers, ip, originalUrl); sendGAServeEvent(headers, ip, originalUrl);
} catch (error) { } catch (error) {

View file

@ -17,7 +17,7 @@ const CONTENT_UNAVAILABLE = 'CONTENT_UNAVAILABLE';
const { publishing: { serveOnlyApproved, approvedChannels } } = require('@config/siteConfig'); const { publishing: { serveOnlyApproved, approvedChannels } } = require('@config/siteConfig');
const getClaimIdAndServeAsset = (channelName, channelClaimId, claimName, claimId, originalUrl, ip, res) => { const getClaimIdAndServeAsset = (channelName, channelClaimId, claimName, claimId, originalUrl, ip, res, headers) => {
getClaimId(channelName, channelClaimId, claimName, claimId) getClaimId(channelName, channelClaimId, claimName, claimId)
.then(fullClaimId => { .then(fullClaimId => {
claimId = fullClaimId; claimId = fullClaimId;
@ -47,6 +47,7 @@ const getClaimIdAndServeAsset = (channelName, channelClaimId, claimName, claimId
logger.debug('Outpoint:', outpoint); logger.debug('Outpoint:', outpoint);
return db.Blocked.isNotBlocked(outpoint).then(() => { return db.Blocked.isNotBlocked(outpoint).then(() => {
// If content was found, is approved, and not blocked - log a view. // If content was found, is approved, and not blocked - log a view.
if(headers && headers['user-agent'] && /LBRY/.test(headers['user-agent']) === false) {
db.Views.create({ db.Views.create({
time: Date.now(), time: Date.now(),
isChannel: false, isChannel: false,
@ -54,6 +55,7 @@ const getClaimIdAndServeAsset = (channelName, channelClaimId, claimName, claimId
publisherId: claimDataValues.publisher_id || claimDataValues.certificateId, publisherId: claimDataValues.publisher_id || claimDataValues.certificateId,
ip, ip,
}); });
}
return; return;
}); });