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
sendGAServeEvent(headers, ip, originalUrl);
// 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;

View file

@ -37,7 +37,7 @@ const serveByClaim = (req, res) => {
({ claimName } = lbryUri.parseClaim(params.claim));
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);
} catch (error) {

View file

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

View file

@ -17,7 +17,7 @@ const CONTENT_UNAVAILABLE = 'CONTENT_UNAVAILABLE';
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)
.then(fullClaimId => {
claimId = fullClaimId;
@ -47,13 +47,15 @@ const getClaimIdAndServeAsset = (channelName, channelClaimId, claimName, claimId
logger.debug('Outpoint:', outpoint);
return db.Blocked.isNotBlocked(outpoint).then(() => {
// If content was found, is approved, and not blocked - log a view.
db.Views.create({
time: Date.now(),
isChannel: false,
claimId: claimDataValues.claim_id || claimDataValues.claimId,
publisherId: claimDataValues.publisher_id || claimDataValues.certificateId,
ip,
});
if(headers && headers['user-agent'] && /LBRY/.test(headers['user-agent']) === false) {
db.Views.create({
time: Date.now(),
isChannel: false,
claimId: claimDataValues.claim_id || claimDataValues.claimId,
publisherId: claimDataValues.publisher_id || claimDataValues.certificateId,
ip,
});
}
return;
});