0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-20 18:22:40 +00:00

Merge pull request #3068 from Gazook89/Prevent-View-Increase-By-Author

Check for author in author list before increasing views.
This commit is contained in:
Trevor Buckner
2023-10-13 23:45:47 -04:00
committed by GitHub

View File

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