fix: don't expose post content on no-unauthenticated (#2584)
parent
7ca6ba2e1c
commit
55ad808785
|
@ -36,11 +36,13 @@ import {Trans, msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {
|
import {
|
||||||
UsePreferencesQueryResponse,
|
UsePreferencesQueryResponse,
|
||||||
|
useModerationOpts,
|
||||||
usePreferencesQuery,
|
usePreferencesQuery,
|
||||||
} from '#/state/queries/preferences'
|
} from '#/state/queries/preferences'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
import {isNative} from '#/platform/detection'
|
import {isNative} from '#/platform/detection'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
|
import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped'
|
||||||
|
|
||||||
const MAINTAIN_VISIBLE_CONTENT_POSITION = {minIndexForVisible: 2}
|
const MAINTAIN_VISIBLE_CONTENT_POSITION = {minIndexForVisible: 2}
|
||||||
|
|
||||||
|
@ -79,14 +81,30 @@ export function PostThread({
|
||||||
data: thread,
|
data: thread,
|
||||||
} = usePostThreadQuery(uri)
|
} = usePostThreadQuery(uri)
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
|
|
||||||
const rootPost = thread?.type === 'post' ? thread.post : undefined
|
const rootPost = thread?.type === 'post' ? thread.post : undefined
|
||||||
const rootPostRecord = thread?.type === 'post' ? thread.record : undefined
|
const rootPostRecord = thread?.type === 'post' ? thread.record : undefined
|
||||||
|
|
||||||
|
const moderationOpts = useModerationOpts()
|
||||||
|
const isNoPwi = React.useMemo(() => {
|
||||||
|
const mod =
|
||||||
|
rootPost && moderationOpts
|
||||||
|
? moderatePost(rootPost, moderationOpts)
|
||||||
|
: undefined
|
||||||
|
|
||||||
|
const cause = mod?.content.cause
|
||||||
|
|
||||||
|
return cause
|
||||||
|
? cause.type === 'label' && cause.labelDef.id === '!no-unauthenticated'
|
||||||
|
: false
|
||||||
|
}, [rootPost, moderationOpts])
|
||||||
|
|
||||||
useSetTitle(
|
useSetTitle(
|
||||||
rootPost &&
|
rootPost && !isNoPwi
|
||||||
`${sanitizeDisplayName(
|
? `${sanitizeDisplayName(
|
||||||
rootPost.author.displayName || `@${rootPost.author.handle}`,
|
rootPost.author.displayName || `@${rootPost.author.handle}`,
|
||||||
)}: "${rootPostRecord?.text}"`,
|
)}: "${rootPostRecord!.text}"`
|
||||||
|
: '',
|
||||||
)
|
)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (rootPost) {
|
if (rootPost) {
|
||||||
|
|
Loading…
Reference in New Issue