Filter hideable content from notifications
This commit is contained in:
@@ -33,14 +33,20 @@ export function isJustAMute(modui: ModerationUI): boolean {
|
||||
return modui.filters.length === 1 && modui.filters[0].type === 'muted'
|
||||
}
|
||||
|
||||
export function isImperative(modui: ModerationUI): boolean {
|
||||
export function moduiContainsHideableOffense(modui: ModerationUI): boolean {
|
||||
const label = modui.filters.at(0)
|
||||
if (label && label.type === 'label') {
|
||||
return ['!hide', '!takedown'].includes(label.label.val)
|
||||
return labelIsHideableOffense(label.label)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
export function labelIsHideableOffense(
|
||||
label: ComAtprotoLabelDefs.Label,
|
||||
): boolean {
|
||||
return ['!hide', '!takedown'].includes(label.val)
|
||||
}
|
||||
|
||||
export function getLabelingServiceTitle({
|
||||
displayName,
|
||||
handle,
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react'
|
||||
import {AppBskyActorDefs, moderateProfile, ModerationOpts} from '@atproto/api'
|
||||
import {keepPreviousData, useQuery, useQueryClient} from '@tanstack/react-query'
|
||||
|
||||
import {isImperative, isJustAMute} from '#/lib/moderation'
|
||||
import {isJustAMute, moduiContainsHideableOffense} from '#/lib/moderation'
|
||||
import {logger} from '#/logger'
|
||||
import {STALE} from '#/state/queries'
|
||||
import {useAgent} from '#/state/session'
|
||||
@@ -114,7 +114,7 @@ function computeSuggestions({
|
||||
const modui = moderateProfile(profile, moderationOpts).ui('profileList')
|
||||
const isExactMatch = q && profile.handle.toLowerCase() === q
|
||||
return (
|
||||
(isExactMatch && !isImperative(modui)) ||
|
||||
(isExactMatch && !moduiContainsHideableOffense(modui)) ||
|
||||
!modui.filter ||
|
||||
isJustAMute(modui)
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
import {QueryClient} from '@tanstack/react-query'
|
||||
import chunk from 'lodash.chunk'
|
||||
|
||||
import {labelIsHideableOffense} from '#/lib/moderation'
|
||||
import {precacheProfile} from '../profile'
|
||||
import {FeedNotification, FeedPage, NotificationType} from './types'
|
||||
|
||||
@@ -104,6 +105,10 @@ export function shouldFilterNotif(
|
||||
notif: AppBskyNotificationListNotifications.Notification,
|
||||
moderationOpts: ModerationOpts | undefined,
|
||||
): boolean {
|
||||
const containsImperative = !!notif.author.labels?.some(labelIsHideableOffense)
|
||||
if (containsImperative) {
|
||||
return true
|
||||
}
|
||||
if (!moderationOpts) {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user