feat: add support for basic web of trust (#65)

Reviewed-on: #65
This commit was merged in pull request #65.
This commit is contained in:
2026-10-20 13:43:37 +00:00
parent a22aecc694
commit f44f0704f3
14 changed files with 720 additions and 241 deletions
+16
View File
@@ -11,9 +11,11 @@ use state::{Announcement, BOOTSTRAP_RELAYS, NostrRegistry, TIMEOUT};
mod directory;
mod person;
mod wot;
pub use directory::*;
pub use person::*;
pub use wot::*;
pub fn init(cx: &mut App) {
PersonRegistry::set_global(cx.new(PersonRegistry::new), cx);
@@ -60,6 +62,8 @@ enum Dispatch {
pub struct PersonRegistry {
/// Public keys with a metadata request in flight
in_flight: RwLock<HashSet<PublicKey>>,
/// Web of trust graph of the signed-in user
wot: Entity<WebOfTrust>,
sender: flume::Sender<PublicKey>,
tasks: SmallVec<[Task<()>; 4]>,
_subscriptions: SmallVec<[Subscription; 1]>,
@@ -80,6 +84,7 @@ impl PersonRegistry {
fn new(cx: &mut Context<Self>) -> Self {
let nostr = NostrRegistry::global(cx);
let client = nostr.read(cx).client();
let wot = cx.new(WebOfTrust::new);
// Channel for communication between nostr and gpui
let (tx, rx) = flume::bounded::<Dispatch>(100);
@@ -122,17 +127,28 @@ impl PersonRegistry {
let subscription = cx.subscribe(&nostr, |this, _nostr, event, cx| {
if event.signer_changed() {
this.get_emojis(cx);
this.wot.update(cx, |wot, cx| {
wot.reset(cx);
wot.hydrate(cx);
});
}
});
Self {
in_flight: RwLock::new(HashSet::new()),
wot,
sender: metadata_tx,
tasks,
_subscriptions: smallvec![subscription],
}
}
/// The web of trust graph of the signed-in user
pub fn wot(&self) -> Entity<WebOfTrust> {
self.wot.clone()
}
/// Handle nostr notifications
async fn handle_notifications(client: &Client, tx: &flume::Sender<Dispatch>) {
let mut notifications = client.notifications();