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