Skip to content

Commit

Permalink
keyword filter for crypto etc
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Jansson committed Sep 12, 2024
1 parent ea42354 commit bdf9aea
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions lib/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,35 @@ export async function getContent(
return [];
}

const filteredPosts = posts.filter(
(post) => post.username && post.username.trim() !== ""
);
const filteredPosts = posts.filter(filterPost);

filteredPosts.sort(customPostSort);

return filteredPosts;
}

function filterPost(post) {
const username = post.username;
const name = post.name.toLowerCase();
const description = post.description ? post.description.toLowerCase() : "";
if (!username || username.trim() == "") {
return false;
}
const bannedStrings = ["nft", "crypto", "telegram", "clicker", "solana", "stealer"];

for (var s of bannedStrings) {
if (name.includes(s) || description.includes(s)) {
return false;
}
}

if (name.includes("stake") && name.includes("predict")) {
return false;
}

return true;
}

function customPostSort(p1, p2) {
const key = (p) =>
p.source == "reddit"
Expand Down

0 comments on commit bdf9aea

Please sign in to comment.