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); +});