0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-17 21:02:49 +00:00

Check for author in author list before increasing views.

This commit is contained in:
Gazook89
2023-09-27 23:46:38 -05:00
parent 52dcc3b53c
commit 1556cf361a

View File

@@ -327,6 +327,8 @@ app.get('/share/:id', asyncHandler(getBrew('share')), asyncHandler(async (req, r
type : 'article' type : 'article'
}; };
// increase visitor view count, do not include visits by author(s)
if(brew.authors.includes(req.account.username) === false){
if(req.params.id.length > 12 && !brew._id) { if(req.params.id.length > 12 && !brew._id) {
const googleId = brew.googleId; const googleId = brew.googleId;
const shareId = brew.shareId; const shareId = brew.shareId;
@@ -335,6 +337,7 @@ app.get('/share/:id', asyncHandler(getBrew('share')), asyncHandler(async (req, r
} else { } else {
await HomebrewModel.increaseView({ shareId: brew.shareId }); await HomebrewModel.increaseView({ shareId: brew.shareId });
} }
};
sanitizeBrew(req.brew, 'share'); sanitizeBrew(req.brew, 'share');
splitTextStyleAndMetadata(req.brew); splitTextStyleAndMetadata(req.brew);
return next(); return next();