diff --git a/.env.docker b/.env.docker index 6c81825f4db..28b4156fd49 100644 --- a/.env.docker +++ b/.env.docker @@ -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="" diff --git a/.env.example b/.env.example index 37e11f12869..4d69443faf9 100644 --- a/.env.example +++ b/.env.example @@ -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="" diff --git a/data/eddiejaoude2.json b/data/eddiejaoude2.json index 49140d1e2d5..1d1e49d1ee5 100644 --- a/data/eddiejaoude2.json +++ b/data/eddiejaoude2.json @@ -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", diff --git a/pages/api/discover/popular.js b/pages/api/discover/popular.js index a34f0dcd27c..0ec60b1d88b 100644 --- a/pages/api/discover/popular.js +++ b/pages/api/discover/popular.js @@ -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"); } diff --git a/pages/api/discover/random.js b/pages/api/discover/random.js index c87c17cfe68..11878dfa4a1 100644 --- a/pages/api/discover/random.js +++ b/pages/api/discover/random.js @@ -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"); } diff --git a/pages/api/discover/trending.js b/pages/api/discover/trending.js index 40cfa8399a1..4b673759002 100644 --- a/pages/api/discover/trending.js +++ b/pages/api/discover/trending.js @@ -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(",") }, }, }, {