Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/gitlawb-node/src/api/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,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,
})
})
.collect();
Expand Down Expand Up @@ -96,6 +97,7 @@ pub async fn list_repo_events(
"new_sha": c.new_sha,
"pusher_did": c.pusher_did,
"node_did": c.node_did,
"owner_did": record.owner_did,
"timestamp": c.issued_at,
"source": "local",
})
Expand Down Expand Up @@ -126,6 +128,7 @@ pub async fn list_repo_events(
"cert_id": u.cert_id,
"received_at": u.received_at,
"from_peer": u.from_peer,
"owner_did": u.owner_did,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
"source": "gossipsub",
})
})
Expand Down
5 changes: 5 additions & 0 deletions crates/gitlawb-node/src/api/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ pub struct NotifyRequest {
pub timestamp: Option<String>,
#[serde(default)]
pub cert_id: Option<String>,
/// Full owner DID — added in #144 for DID-aware feed gating.
/// Optional for backward compat with older senders.
#[serde(default)]
pub owner_did: Option<String>,
}

pub async fn notify_sync(
Expand Down Expand Up @@ -391,6 +395,7 @@ pub async fn notify_sync(
node_did: req.node_did.clone(),
pusher_did: req.pusher_did.clone().unwrap_or_default(),
repo: req.repo.clone(),
owner_did: req.owner_did.clone(),
ref_name: req.ref_name.clone(),
old_sha: req.old_sha.clone().unwrap_or_default(),
new_sha: req.new_sha.clone(),
Expand Down
18 changes: 18 additions & 0 deletions crates/gitlawb-node/src/api/repos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ async fn notify_peer_of_ref(
new_sha: &str,
node_did: &str,
pusher_did: &str,
owner_did: &str,
) {
let body = serde_json::json!({
"repo": repo_slug,
Expand All @@ -720,6 +721,7 @@ async fn notify_peer_of_ref(
"pusher_did": pusher_did,
"old_sha": old_sha,
"timestamp": chrono::Utc::now().to_rfc3339(),
"owner_did": owner_did,
});
let body_bytes = match serde_json::to_vec(&body) {
Ok(bytes) => bytes,
Expand Down Expand Up @@ -767,6 +769,7 @@ async fn notify_peer_of_refs(
ref_updates: &[(String, String, String)],
node_did: &str,
pusher_did: &str,
owner_did: &str,
) {
for (ref_name, old_sha, new_sha) in ref_updates {
notify_peer_of_ref(
Expand All @@ -780,6 +783,7 @@ async fn notify_peer_of_refs(
new_sha,
node_did,
pusher_did,
owner_did,
)
.await;
}
Expand Down Expand Up @@ -1200,6 +1204,7 @@ pub async fn git_receive_pack(
node_did: node_did_str.clone(),
pusher_did: pusher_did_clone.clone(),
repo: repo_slug.clone(),
owner_did: Some(record.owner_did.clone()),
ref_name: ref_name.clone(),
old_sha: old_sha.clone(),
new_sha: new_sha.clone(),
Expand All @@ -1223,6 +1228,7 @@ pub async fn git_receive_pack(
pusher_did: pusher_did_clone.clone(),
node_did: node_did_str.clone(),
timestamp: now_ts.clone(),
owner_did: Some(owner_did_for_arweave.clone()),
});
}

Expand Down Expand Up @@ -1292,6 +1298,7 @@ pub async fn git_receive_pack(
&ref_updates_clone,
&node_did_str,
&pusher_did_clone,
&record.owner_did,
)
.await;
}
Expand Down Expand Up @@ -2259,6 +2266,9 @@ mod tests {
mockito::Matcher::PartialJsonString(format!(r#"{{"ref_name":"{ref_a}"}}"#)),
mockito::Matcher::PartialJsonString(format!(r#"{{"old_sha":"{old_a}"}}"#)),
mockito::Matcher::PartialJsonString(format!(r#"{{"new_sha":"{new_a}"}}"#)),
mockito::Matcher::PartialJsonString(
r#"{"owner_did":"did:key:zOwner"}"#.to_string(),
),
]))
.with_status(200)
.expect(1)
Expand All @@ -2270,6 +2280,9 @@ mod tests {
mockito::Matcher::PartialJsonString(format!(r#"{{"ref_name":"{ref_b}"}}"#)),
mockito::Matcher::PartialJsonString(format!(r#"{{"old_sha":"{old_b}"}}"#)),
mockito::Matcher::PartialJsonString(format!(r#"{{"new_sha":"{new_b}"}}"#)),
mockito::Matcher::PartialJsonString(
r#"{"owner_did":"did:key:zOwner"}"#.to_string(),
),
]))
.with_status(200)
.expect(1)
Expand All @@ -2291,6 +2304,7 @@ mod tests {
&ref_updates,
"did:key:zNode",
"did:key:zPusher",
"did:key:zOwner",
)
.await;

Expand All @@ -2313,6 +2327,9 @@ mod tests {
.match_body(mockito::Matcher::AllOf(vec![
mockito::Matcher::PartialJsonString(format!(r#"{{"old_sha":"{zero}"}}"#)),
mockito::Matcher::PartialJsonString(format!(r#"{{"new_sha":"{new_sha}"}}"#)),
mockito::Matcher::PartialJsonString(
r#"{"owner_did":"did:key:zOwner"}"#.to_string(),
),
]))
.with_status(200)
.expect(1)
Expand All @@ -2335,6 +2352,7 @@ mod tests {
&ref_updates,
"did:key:zNode",
"did:key:zPusher",
"did:key:zOwner",
)
.await;

Expand Down
Loading
Loading