Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(node): show local owner on global feed, assert nullable in migrat…
…ion test, add owner_did echo assertions
  • Loading branch information
Gravirei committed Jul 15, 2026
commit 6b45dc37648bf6aa363a63275f0a4bec004d9187
27 changes: 25 additions & 2 deletions crates/gitlawb-node/src/api/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,25 @@ pub async fn list_ref_updates(
let caller = auth.as_ref().map(|e| e.0 .0.as_str());
let updates = collect_visible_ref_updates(&state.db, None, limit, caller).await?;

// Resolve the local owner_did for each row so locally-hosted repos
// display their canonical owner rather than a peer-supplied wire value.
let deduped = state.db.list_all_repos_deduped().await?;
let resolve_local = |slug: &str| -> Option<&str> {
for record in &deduped {
if crate::visibility::ref_update_row_names_repo(record, slug) {
return Some(&record.owner_did);
}
}
None
};

let events: Vec<serde_json::Value> = updates
.iter()
.map(|u| {
let owner_did = match resolve_local(&u.repo) {
Some(local) => serde_json::json!(local),
None => serde_json::json!(u.owner_did),
};
serde_json::json!({
"id": u.id,
"node_did": u.node_did,
Expand All @@ -153,7 +169,7 @@ pub async fn list_ref_updates(
"cert_id": u.cert_id,
"received_at": u.received_at,
"from_peer": u.from_peer,
"owner_did": u.owner_did,
"owner_did": owner_did,
})
})
.collect();
Expand Down Expand Up @@ -1109,7 +1125,14 @@ mod ref_updates_feed_tests {
.await
.unwrap();
assert_eq!(resp.status(), StatusCode::OK);
assert_eq!(count(&body_json(resp).await), 2);
let body = body_json(resp).await;
assert_eq!(count(&body), 2);
for event in body["events"].as_array().unwrap() {
assert_eq!(
event["owner_did"], OWNER,
"each event must carry the local owner_did"
);
}
}

// Anon reads a quarantined mirror → 404 (withheld without disclosing existence
Expand Down
1 change: 1 addition & 0 deletions crates/gitlawb-node/src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3512,6 +3512,7 @@ mod migration_tests {
.unwrap();
assert_eq!(col.0, "owner_did");
assert_eq!(col.1, "text");
assert_eq!(col.2, "YES", "owner_did must be nullable");

// (c) Version 11 is recorded as applied.
let v11_count: (i64,) =
Expand Down
8 changes: 6 additions & 2 deletions crates/gitlawb-node/src/graphql/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ mod tests {
.await
.unwrap();
let schema = schema(db);
let q = r#"{ refUpdates { repo refName } }"#;
let q = r#"{ refUpdates { repo refName ownerDid } }"#;
let resp = anon(&schema, q).await;
assert_eq!(count(&resp), 1);
// The one row returned must be the public repo's.
// The one row returned must be the public repo's with owner_did echoed.
let async_graphql::Value::Object(obj) = &resp.data else {
unreachable!()
};
Expand All @@ -264,6 +264,10 @@ mod tests {
row.get("repo").unwrap(),
&async_graphql::Value::from("z6MkOwner/openrepo")
);
assert!(
row.contains_key("ownerDid"),
"ownerDid must be present in the refUpdates response"
);
}

// Scenario 4 — alias fail-closed: private repo's row stored full-DID form.
Expand Down