feat: trust score filter
This commit is contained in:
parent
43f4c34fb3
commit
5f785e5553
48 changed files with 974 additions and 480 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue