mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-04 20:02:26 +00:00
feat: incorporate tag preferences into blacklist filter stage
- Implements `hasDisinterestedTag` helper in `js/feedEngine/utils.js` to check for disinterested tags in both raw Nostr tags and NIP-71 metadata. - Updates `createBlacklistFilterStage` in `js/feedEngine/stages.js` to filter out videos matching `context.runtime.tagPreferences` disinterests. - Ensures existing blacklist logic remains undisturbed. - Verified with new unit test `tests/feed-engine-tag-pref.test.mjs` and existing feed engine tests.
This commit is contained in:
1 parent
05292925c8
commit
7d274bc331
2 files changed
+43
-4
No files matched your search
@@ -27,3 +27,31 @@ export function toArray(value) {
|
||||
}
|
||||
return [value];
|
||||
}
|
||||
|
||||
export function hasDisinterestedTag(video, disinterestsSet) {
|
||||
if (!video || !disinterestsSet || !(disinterestsSet instanceof Set) || disinterestsSet.size === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check raw tags
|
||||
if (Array.isArray(video.tags)) {
|
||||
for (const tag of video.tags) {
|
||||
if (Array.isArray(tag) && tag[0] === "t" && typeof tag[1] === "string") {
|
||||
if (disinterestsSet.has(tag[1].toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check NIP-71 metadata hashtags if available
|
||||
if (video.nip71 && Array.isArray(video.nip71.hashtags)) {
|
||||
for (const tag of video.nip71.hashtags) {
|
||||
if (typeof tag === "string" && disinterestsSet.has(tag.toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
Reference in new issue
Block a user