add spam badge for requests
This commit is contained in:
+24
-2
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user