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,13 +47,15 @@ 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.
db.Views.create({ if(headers && headers['user-agent'] && /LBRY/.test(headers['user-agent']) === false) {
time: Date.now(), db.Views.create({
isChannel: false, time: Date.now(),
claimId: claimDataValues.claim_id || claimDataValues.claimId, isChannel: false,
publisherId: claimDataValues.publisher_id || claimDataValues.certificateId, claimId: claimDataValues.claim_id || claimDataValues.claimId,
ip, publisherId: claimDataValues.publisher_id || claimDataValues.certificateId,
}); ip,
});
}
return; return;
}); });