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
+27
View File
@@ -434,6 +434,11 @@ impl WebOfTrust {
self.follows.contains(public_key) || self.score(public_key) > 0
}
/// Whether the graph is loaded and the public key is outside the network
pub fn is_outside(&self, public_key: &PublicKey) -> bool {
self.ready && !self.disabled && !self.is_in_network(public_key)
}
/// The current user's contacts who follow the public key
pub fn mutuals(&self, public_key: &PublicKey) -> Vec<PublicKey> {
self.reverse
@@ -572,6 +577,28 @@ mod tests {
assert!(wot.reverse.is_empty());
}
#[test]
fn outside_requires_a_loaded_graph() {
let mut wot = registry();
let (me, alice, carol) = (key(1), key(2), key(3));
wot.self_key = Some(me);
wot.store_follows(Some(Timestamp::from_secs(10)), HashSet::from([alice]));
// The graph is not loaded yet
assert!(!wot.is_outside(&carol));
wot.ready = true;
assert!(wot.is_outside(&carol));
assert!(!wot.is_outside(&alice));
// A disabled graph marks nothing as outside
wot.disabled = true;
assert!(!wot.is_outside(&carol));
}
#[test]
fn caps_ingested_contact_lists() {
let mut wot = registry();