mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Propagate tag preferences through feed runtimes
This commit is contained in:
1 parent
d5f2539b56
commit
ad01cf852f
4 files changed
+46
-1
No files matched your search
@@ -6434,6 +6434,9 @@ class Application {
|
||||
return this.feedEngine.registerFeed("recent", {
|
||||
source: createActiveNostrSource({ service: this.nostrService }),
|
||||
stages: [
|
||||
// TODO(tag-preferences): introduce a dedicated stage here to filter by
|
||||
// viewer interests/disinterests once the runtime metadata is wired up
|
||||
// to filtering helpers.
|
||||
createBlacklistFilterStage({
|
||||
shouldIncludeVideo: (video, options) =>
|
||||
this.nostrService.shouldIncludeVideo(video, options),
|
||||
@@ -6475,6 +6478,8 @@ class Application {
|
||||
return this.feedEngine.registerFeed("subscriptions", {
|
||||
source: createSubscriptionAuthorsSource({ service: this.nostrService }),
|
||||
stages: [
|
||||
// TODO(tag-preferences): introduce preference-aware filtering ahead of
|
||||
// the blacklist stage when tag-based ranking lands.
|
||||
createBlacklistFilterStage({
|
||||
shouldIncludeVideo: (video, options) =>
|
||||
this.nostrService.shouldIncludeVideo(video, options),
|
||||
@@ -6533,9 +6538,19 @@ class Application {
|
||||
? new Set(this.blacklistedEventIds)
|
||||
: new Set();
|
||||
|
||||
const preferenceSource =
|
||||
typeof this.getHashtagPreferences === "function"
|
||||
? this.getHashtagPreferences()
|
||||
: {};
|
||||
const { interests = [], disinterests = [] } = preferenceSource || {};
|
||||
|
||||
return {
|
||||
blacklistedEventIds: blacklist,
|
||||
isAuthorBlocked: (pubkey) => this.isAuthorBlocked(pubkey),
|
||||
tagPreferences: {
|
||||
interests: Array.isArray(interests) ? [...interests] : [],
|
||||
disinterests: Array.isArray(disinterests) ? [...disinterests] : [],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,10 @@ export function createBlacklistFilterStage({
|
||||
|
||||
const options = { blacklistedEventIds: blacklist, isAuthorBlocked };
|
||||
|
||||
// TODO(tag-preferences): incorporate context.runtime.tagPreferences once the
|
||||
// filtering helpers are in place so this stage can drop disinterested tags
|
||||
// without disturbing existing blacklist logic.
|
||||
|
||||
const results = [];
|
||||
|
||||
for (const item of items) {
|
||||
|
||||
@@ -103,6 +103,19 @@ function buildWatchHistoryFeedRuntime({ actor, cursor = 0 } = {}) {
|
||||
}
|
||||
};
|
||||
|
||||
const preferenceSource =
|
||||
typeof app?.getHashtagPreferences === "function"
|
||||
? app.getHashtagPreferences()
|
||||
: {};
|
||||
runtime.tagPreferences = {
|
||||
interests: Array.isArray(preferenceSource?.interests)
|
||||
? [...preferenceSource.interests]
|
||||
: [],
|
||||
disinterests: Array.isArray(preferenceSource?.disinterests)
|
||||
? [...preferenceSource.disinterests]
|
||||
: []
|
||||
};
|
||||
|
||||
if (normalizedActor) {
|
||||
runtime.actor = normalizedActor;
|
||||
}
|
||||
|
||||
+14
-1
@@ -878,12 +878,25 @@ class SubscriptionsManager {
|
||||
? Math.floor(limitCandidate)
|
||||
: null;
|
||||
|
||||
const preferenceSource =
|
||||
typeof app?.getHashtagPreferences === "function"
|
||||
? app.getHashtagPreferences()
|
||||
: {};
|
||||
|
||||
return {
|
||||
subscriptionAuthors: normalizedAuthors,
|
||||
authors: normalizedAuthors,
|
||||
blacklistedEventIds: blacklist,
|
||||
isAuthorBlocked,
|
||||
limit: normalizedLimit
|
||||
limit: normalizedLimit,
|
||||
tagPreferences: {
|
||||
interests: Array.isArray(preferenceSource?.interests)
|
||||
? [...preferenceSource.interests]
|
||||
: [],
|
||||
disinterests: Array.isArray(preferenceSource?.disinterests)
|
||||
? [...preferenceSource.disinterests]
|
||||
: [],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user