Merge pull request #945 from PR0M3TH3AN/codex/fix-video-filtering-for-logged-in-user

Ensure authors always see their own videos
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2025-10-26 19:39:32 -04:00
commit a667278db3
2 files changed
+37 -2

No files matched your search

+6 -2
View File
@@ -582,7 +582,11 @@ export class NostrService {
const viewerIsAuthor = this.isViewerVideoAuthor(video);
if (ALLOW_NSFW_CONTENT !== true && video.isNsfw === true && !viewerIsAuthor) {
if (viewerIsAuthor) {
return true;
}
if (ALLOW_NSFW_CONTENT !== true && video.isNsfw === true) {
return false;
}
@@ -600,7 +604,7 @@ export class NostrService {
}
}
if (video.isPrivate === true && !viewerIsAuthor) {
if (video.isPrivate === true) {
return false;
}
@@ -127,3 +127,34 @@ test("shouldIncludeVideo rejects blacklisted authors provided as hex when npubEn
globalThis.window.NostrTools.nip19.npubEncode = originalEncode;
}
});
test("shouldIncludeVideo always returns true for the viewer's own video", () => {
const service = createServiceWithAccessControl();
const video = {
id: "viewer-owned-video",
kind: 30078,
pubkey: whitelistHex,
};
service.nostrClient = { pubkey: whitelistHex };
const blacklistedEventIds = new Set([video.id]);
assert.equal(
service.shouldIncludeVideo(video, { blacklistedEventIds }),
true,
);
});
test("shouldIncludeVideo allows access when access control would deny the author", () => {
const service = new NostrService();
service.accessControl = { canAccess: () => false };
service.nostrClient = { pubkey: whitelistHex };
const video = {
id: "access-control-denied-video",
kind: 30078,
pubkey: whitelistHex,
};
assert.equal(service.shouldIncludeVideo(video), true);
});