Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

feat: shadowban from discover page #3581

Merged
merged 1 commit into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ LINKFREE_MONGO_CONNECTION_STRING="mongodb://mongodb:27017/linkfree"
NEXT_PUBLIC_GA_MEASUREMENT_ID=""
NEXT_PUBLIC_BASE_URL="http://localhost:3000"
NODE_ENV="development"
SHADOWBAN=""
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ LINKFREE_MONGO_CONNECTION_STRING="mongodb://localhost:27017/linkfree"
NEXT_PUBLIC_GA_MEASUREMENT_ID=""
NEXT_PUBLIC_BASE_URL="http://localhost:3000"
NODE_ENV="development"
SHADOWBAN=""
1 change: 1 addition & 0 deletions data/eddiejaoude2.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "Eddie Jaoude Test profile",
"displayStatsPublic": true,
"type": "personal",
"bio": "This is my profile where I test stuff",
"avatar": "https://github.com/eddiejaoude2.png",
Expand Down
6 changes: 5 additions & 1 deletion pages/api/discover/popular.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ export default async function handler(req, res) {

let popularProfiles = [];
try {
popularProfiles = await Profile.find({}).sort({ views: -1 }).limit(20);
popularProfiles = await Profile.find({
username: { $nin: process.env.SHADOWBAN.split(",") },
})
.sort({ views: -1 })
.limit(20);
} catch (e) {
logger.error(e, "failed to load profiles");
}
Expand Down
5 changes: 4 additions & 1 deletion pages/api/discover/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export default async function handler(req, res) {

let randomProfiles = [];
try {
randomProfiles = await Profile.aggregate([{ $sample: { size: 5 } }]);
randomProfiles = await Profile.aggregate([
{ $sample: { size: 5 } },
{ $match: { username: { $nin: process.env.SHADOWBAN.split(",") } } },
]);
} catch (e) {
logger.error(e, "failed to load profiles");
}
Expand Down
1 change: 1 addition & 0 deletions pages/api/discover/trending.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default async function handler(req, res) {
date: {
$gte: new Date(new Date().setDate(new Date().getDate() - 1)),
},
username: { $nin: process.env.SHADOWBAN.split(",") },
},
},
{
Expand Down