mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 21:02:28 +00:00
Fix viewer mute blur regression and update modal overrides
This commit is contained in:
1 parent
3936b1ed9f
commit
9dfe7ef20e
5 files changed
+193
-11
No files matched your search
@@ -496,6 +496,76 @@ test("moderation stage propagates whitelist, muters, and threshold updates", asy
|
||||
assert.equal(updatedMuted.video.moderation.blurReason, undefined);
|
||||
});
|
||||
|
||||
test("moderation stage blurs viewer-muted authors", async () => {
|
||||
const mutedHex = "f".repeat(64);
|
||||
|
||||
const service = {
|
||||
async refreshViewerFromClient() {},
|
||||
async setActiveEventIds() {},
|
||||
getAdminListSnapshot() {
|
||||
return { whitelist: new Set(), whitelistHex: new Set(), blacklist: new Set(), blacklistHex: new Set() };
|
||||
},
|
||||
getAccessControlStatus(identifier) {
|
||||
return { hex: identifier, whitelisted: false, blacklisted: false };
|
||||
},
|
||||
getTrustedReportSummary() {
|
||||
return null;
|
||||
},
|
||||
trustedReportCount() {
|
||||
return 0;
|
||||
},
|
||||
getTrustedReporters() {
|
||||
return [];
|
||||
},
|
||||
isAuthorMutedByTrusted() {
|
||||
return false;
|
||||
},
|
||||
isAuthorMutedByViewer(pubkey) {
|
||||
return pubkey === mutedHex;
|
||||
},
|
||||
};
|
||||
|
||||
const stage = createModerationStage({
|
||||
service,
|
||||
autoplayThreshold: Number.POSITIVE_INFINITY,
|
||||
blurThreshold: Number.POSITIVE_INFINITY,
|
||||
trustedMuteHideThreshold: Number.POSITIVE_INFINITY,
|
||||
trustedReportHideThreshold: Number.POSITIVE_INFINITY,
|
||||
});
|
||||
|
||||
const items = [{ video: { id: "viewer-muted", pubkey: mutedHex }, metadata: {} }];
|
||||
|
||||
const reasons = [];
|
||||
const context = {
|
||||
addWhy(detail) {
|
||||
reasons.push(detail);
|
||||
return detail;
|
||||
},
|
||||
log() {},
|
||||
};
|
||||
|
||||
const result = await stage(items, context);
|
||||
|
||||
assert.equal(result.length, 1);
|
||||
const entry = result[0];
|
||||
|
||||
assert.equal(entry.video.moderation.viewerMuted, true);
|
||||
assert.equal(entry.metadata.moderation.viewerMuted, true);
|
||||
assert.equal(entry.video.moderation.blockAutoplay, true);
|
||||
assert.equal(entry.video.moderation.blurThumbnail, true);
|
||||
assert.equal(entry.video.moderation.blurReason, "viewer-mute");
|
||||
assert.equal(entry.metadata.moderation.blurReason, "viewer-mute");
|
||||
assert.equal(entry.video.moderation.hidden, false);
|
||||
assert.equal(entry.metadata.moderation.hidden, false);
|
||||
assert.equal(entry.video.moderation.hideReason, undefined);
|
||||
assert.equal(entry.metadata.moderation.hideReason, undefined);
|
||||
assert.equal(entry.metadata.moderation.hideCounts, undefined);
|
||||
|
||||
const reasonSet = new Set(reasons.map((detail) => detail.reason));
|
||||
assert(reasonSet.has("blur"));
|
||||
assert(reasonSet.has("viewer-mute"));
|
||||
});
|
||||
|
||||
test("moderation stage clears cached reporters and muters after service signals", async () => {
|
||||
const reporterHex = "d".repeat(64);
|
||||
const muterHex = "e".repeat(64);
|
||||
|
||||
@@ -271,6 +271,58 @@ test(
|
||||
},
|
||||
);
|
||||
|
||||
test("VideoCard blurs viewer-muted creators", async (t) => {
|
||||
const { document } = setupDom(t);
|
||||
withMockedNostrTools(t);
|
||||
|
||||
const app = await createModerationAppHarness();
|
||||
const videoId = "d".repeat(64);
|
||||
|
||||
const video = {
|
||||
id: videoId,
|
||||
title: "Muted Creator Clip",
|
||||
pubkey: "e".repeat(64),
|
||||
moderation: {
|
||||
viewerMuted: true,
|
||||
blockAutoplay: true,
|
||||
blurThumbnail: true,
|
||||
blurReason: "viewer-mute",
|
||||
trustedCount: 0,
|
||||
trustedMuted: false,
|
||||
trustedReporters: [],
|
||||
},
|
||||
};
|
||||
|
||||
app.videosMap.set(video.id, video);
|
||||
app.currentVideo = video;
|
||||
app.decorateVideoModeration(video);
|
||||
|
||||
const card = new VideoCard({
|
||||
document,
|
||||
video,
|
||||
formatters: {
|
||||
formatTimeAgo: () => "moments ago",
|
||||
},
|
||||
helpers: {
|
||||
isMagnetSupported: () => false,
|
||||
},
|
||||
});
|
||||
|
||||
document.body.appendChild(card.getRoot());
|
||||
|
||||
assert.equal(card.getRoot().dataset.autoplayPolicy, "blocked");
|
||||
assert.equal(card.thumbnailEl.dataset.thumbnailState, "blurred");
|
||||
|
||||
const context = normalizeVideoModerationContext(card.video?.moderation);
|
||||
assert.equal(context.blurReason, "viewer-mute");
|
||||
assert.equal(context.activeBlur, true);
|
||||
assert.equal(context.activeBlockAutoplay, true);
|
||||
assert.equal(context.trustedCount, 0);
|
||||
assert.equal(card.getRoot().dataset.moderationReportCount, undefined);
|
||||
assert.ok(card.moderationBadgeEl);
|
||||
assert.equal(card.moderationBadgeEl.dataset.moderationState, "blocked");
|
||||
});
|
||||
|
||||
test("VideoCard blurs thumbnails when trusted mute triggers without reports", async (t) => {
|
||||
const { document } = setupDom(t);
|
||||
withMockedNostrTools(t);
|
||||
|
||||
Reference in new issue
Block a user