From 9a75dd1bde29240252055805c051d7e29a491c72 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Sun, 26 Oct 2025 19:38:09 -0400 Subject: [PATCH] Ensure authors always see their own videos --- js/services/nostrService.js | 8 ++++-- tests/nostr-service-access-control.test.mjs | 31 +++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/js/services/nostrService.js b/js/services/nostrService.js index 2a180e49..20cbe5e0 100644 --- a/js/services/nostrService.js +++ b/js/services/nostrService.js @@ -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; } diff --git a/tests/nostr-service-access-control.test.mjs b/tests/nostr-service-access-control.test.mjs index 513102e2..9e8dad17 100644 --- a/tests/nostr-service-access-control.test.mjs +++ b/tests/nostr-service-access-control.test.mjs @@ -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); +});