diff --git a/server/controllers/assets/serveAsset/index.js b/server/controllers/assets/serveAsset/index.js index 3f0149a8..c953ca51 100644 --- a/server/controllers/assets/serveAsset/index.js +++ b/server/controllers/assets/serveAsset/index.js @@ -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; diff --git a/server/controllers/assets/serveByClaim/index.js b/server/controllers/assets/serveByClaim/index.js index a2b091a9..ef9278de 100644 --- a/server/controllers/assets/serveByClaim/index.js +++ b/server/controllers/assets/serveByClaim/index.js @@ -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) { diff --git a/server/controllers/assets/serveByIdentifierAndClaim/index.js b/server/controllers/assets/serveByIdentifierAndClaim/index.js index 4e4d66b1..bdba8e7e 100644 --- a/server/controllers/assets/serveByIdentifierAndClaim/index.js +++ b/server/controllers/assets/serveByIdentifierAndClaim/index.js @@ -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) { diff --git a/server/controllers/assets/utils/getClaimIdAndServeAsset.js b/server/controllers/assets/utils/getClaimIdAndServeAsset.js index 26c6805d..158d93b6 100644 --- a/server/controllers/assets/utils/getClaimIdAndServeAsset.js +++ b/server/controllers/assets/utils/getClaimIdAndServeAsset.js @@ -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; });