Show NSFW-node members unblurred media and brand maintenance screens per node

Hop-State: A_06FP9J7X3NRW462MRQP41Z0
Hop-Proposal: R_06FP9J6Q5X4KY348B7CJS28
Hop-Task: T_06FP9GSP35DQFZ5RXET13S0
Hop-Attempt: AT_06FP9GSP348ZKDWV5HCQYPG
This commit is contained in:
2026-07-15 00:58:41 -07:00
committed by Hop
parent de5ba47834
commit f435e62220
7 changed files with 126 additions and 11 deletions
+11 -2
View File
@@ -6,8 +6,17 @@ describe('shouldBlurProfileMedia', () => {
expect(shouldBlurProfileMedia({ accountIsNsfw: true, viewer: null })).toBe(true);
});
it('blurs every account from an NSFW node when the viewer has NSFW disabled', () => {
expect(shouldBlurProfileMedia({ nodeIsNsfw: true, viewer: { nsfwEnabled: false } })).toBe(true);
it('blurs media from an NSFW node for a viewer on a non-NSFW node with NSFW disabled', () => {
expect(shouldBlurProfileMedia({ nodeIsNsfw: true, localNodeIsNsfw: false, viewer: { nsfwEnabled: false } })).toBe(true);
});
it('shows sensitive media to an authenticated member of the local NSFW node', () => {
expect(shouldBlurProfileMedia({
accountIsNsfw: true,
nodeIsNsfw: true,
localNodeIsNsfw: true,
viewer: { nsfwEnabled: false },
})).toBe(false);
});
it('shows sensitive profile media when the viewer has enabled NSFW', () => {
+8 -1
View File
@@ -5,11 +5,18 @@ export interface ProfileMediaViewer {
export function shouldBlurProfileMedia({
accountIsNsfw = false,
nodeIsNsfw = false,
localNodeIsNsfw = false,
viewer,
}: {
accountIsNsfw?: boolean;
nodeIsNsfw?: boolean;
localNodeIsNsfw?: boolean;
viewer: ProfileMediaViewer | null;
}): boolean {
return (accountIsNsfw || nodeIsNsfw) && viewer?.nsfwEnabled !== true;
if (!accountIsNsfw && !nodeIsNsfw) return false;
if (!viewer) return true;
// Signing in to an NSFW node is itself consent to view that node's media.
// The explicit preference still controls sensitive media on non-NSFW nodes.
return viewer.nsfwEnabled !== true && !localNodeIsNsfw;
}