add spam badge for requests

This commit is contained in:
2026-10-20 10:53:45 +07:00
parent 10d74c5396
commit 9143de6cfe
7 changed files with 93 additions and 54 deletions
+24 -2
View File
@@ -192,16 +192,38 @@ impl Room {
let wot = WebOfTrust::global(cx).read(cx);
Self::trusted_by(&self.members, me, |key| wot.is_in_network(key))
}
/// Whether the room looks like spam: everyone other than the current user
/// is outside the web of trust
pub fn is_spam(&self, cx: &App) -> bool {
let nostr = NostrRegistry::global(cx);
let Some(me) = nostr.read(cx).current_user() else {
return false;
};
let wot = WebOfTrust::global(cx).read(cx);
Self::trusted_by(&self.members, me, |key| !wot.is_outside(key))
}
/// Whether every member other than `me` passes the check
fn trusted_by(
members: &[PublicKey],
me: PublicKey,
check: impl Fn(&PublicKey) -> bool,
) -> bool {
let mut others = false;
for key in &self.members {
for key in members {
if *key == me {
continue;
}
others = true;
if !wot.is_in_network(key) {
if !check(key) {
return false;
}
}