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:
@@ -22,9 +22,11 @@ export function AvatarImage({ avatarUrl, seed, isNsfw = false, nodeIsNsfw, alt =
|
||||
const { config } = useRuntimeConfig();
|
||||
const customAvatar = avatarUrl?.trim();
|
||||
const src = customAvatar && failedAvatarUrl !== customAvatar ? customAvatar : getDiceBearAvatarUrl(seed);
|
||||
const localNodeIsNsfw = config?.isNsfw ?? false;
|
||||
const blurred = shouldBlurProfileMedia({
|
||||
accountIsNsfw: isNsfw,
|
||||
nodeIsNsfw: nodeIsNsfw ?? config?.isNsfw ?? false,
|
||||
nodeIsNsfw: nodeIsNsfw ?? localNodeIsNsfw,
|
||||
localNodeIsNsfw,
|
||||
viewer: user,
|
||||
});
|
||||
|
||||
|
||||
@@ -21,9 +21,11 @@ export function ProfileBanner({
|
||||
}) {
|
||||
const { user } = useAuth();
|
||||
const { config } = useRuntimeConfig();
|
||||
const localNodeIsNsfw = config?.isNsfw ?? false;
|
||||
const blurred = shouldBlurProfileMedia({
|
||||
accountIsNsfw: isNsfw,
|
||||
nodeIsNsfw: nodeIsNsfw ?? config?.isNsfw ?? false,
|
||||
nodeIsNsfw: nodeIsNsfw ?? localNodeIsNsfw,
|
||||
localNodeIsNsfw,
|
||||
viewer: user,
|
||||
});
|
||||
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user