feat: trust score filter

This commit is contained in:
codytseng 2025-12-31 18:22:23 +08:00
parent 43f4c34fb3
commit 5f785e5553
48 changed files with 974 additions and 480 deletions

View file

@ -2,26 +2,24 @@ import { kinds, NostrEvent } from 'nostr-tools'
import { isMentioningMutedUsers } from './event'
import { tagNameEquals } from './tag'
export function notificationFilter(
export async function notificationFilter(
event: NostrEvent,
{
pubkey,
mutePubkeySet,
hideContentMentioningMutedUsers,
hideUntrustedNotifications,
isUserTrusted
meetsMinTrustScore
}: {
pubkey?: string | null
mutePubkeySet: Set<string>
hideContentMentioningMutedUsers?: boolean
hideUntrustedNotifications?: boolean
isUserTrusted: (pubkey: string) => boolean
meetsMinTrustScore: (pubkey: string, minScore?: number) => Promise<boolean>
}
): boolean {
): Promise<boolean> {
if (
mutePubkeySet.has(event.pubkey) ||
(hideContentMentioningMutedUsers && isMentioningMutedUsers(event, mutePubkeySet)) ||
(hideUntrustedNotifications && !isUserTrusted(event.pubkey))
!(await meetsMinTrustScore(event.pubkey))
) {
return false
}