Skip to content

Commit

Permalink
hide note by pow difficulty
Browse files Browse the repository at this point in the history
  • Loading branch information
ticruz38 committed Jan 21, 2025
1 parent e19f3a4 commit 71de0b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/app/views/UserContent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@
score. Notes from accounts with a lower score will be automatically hidden.
</p>
</Field>
<Field>
<div slot="label" class="flex justify-between">
<strong>Minimum PoW</strong>
<div>{values.min_pow_difficulty}</div>
</div>
<Input type="range" bind:value={values.min_pow_difficulty} step="4" min={0} max={32} />
<p slot="info">
Select a minimum proof-of-work difficulty. Notes with a lower Web Of Trust and PoW difficulty will be hidden.
</p>
</Field>
<Field label="Muted accounts">
<PersonSelect multiple bind:value={mutedPubkeys} />
<p slot="info">Notes from these people will be hidden by default.</p>
Expand Down
8 changes: 7 additions & 1 deletion src/engine/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ import {
normalizeRelayUrl,
readList,
getReplyTagValues,
getTag,
} from "@welshman/util"
import Fuse from "fuse.js"
import {batch, doPipe, seconds} from "hurdak"
Expand Down Expand Up @@ -269,6 +270,7 @@ export const defaultSettings = {
hide_sensitive: true,
report_analytics: true,
min_wot_score: 0,
min_pow_difficulty: 0,
enable_client_tag: false,
auto_authenticate: false,
note_actions: ["zaps", "replies", "reactions", "recommended_apps"],
Expand Down Expand Up @@ -356,6 +358,7 @@ export const isEventMuted = withGetter(
([$userMutes, $userFollows, $userSettings, $pubkey]) => {
const words = $userSettings.muted_words
const minWot = $userSettings.min_wot_score
const minPow = $userSettings.min_pow_difficulty
const regex =
words.length > 0
? new RegExp(`\\b(${words.map(w => w.toLowerCase().trim()).join("|")})\\b`)
Expand All @@ -376,8 +379,11 @@ export const isEventMuted = withGetter(
if (strict || $userFollows.has(e.pubkey)) return false

const wotScore = getUserWotScore(e.pubkey)
const powDifficulty = Number(getTag("nonce", e.tags)?.[2] || "0")

return wotScore < minWot
const isValidPow = e.id.startsWith("0".repeat(Math.ceil(powDifficulty / 4)))

return wotScore < minWot && (powDifficulty < minPow || !isValidPow)
}
},
),
Expand Down

0 comments on commit 71de0b6

Please sign in to comment.