mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-02 02:42:28 +00:00
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:
2 files changed
+37
-2
No files matched your search
@@ -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);
|
||||
});
|
||||
Reference in new issue
Block a user