Merge pull request #896 from PR0M3TH3AN/codex/update-feed-runtime-initialization-and-subscription

Propagate tag preferences through feed runtimes
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2025-10-25 17:38:56 -04:00
commit 1aa9eec6d1
4 files changed
+46 -1

No files matched your search

+15
View File
@@ -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] : [],
},
};
}
+4
View File
@@ -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) {
+13
View File
@@ -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
View File
@@ -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]
: [],
},
};
}