feat: integrate DWN protocols with content and federation flows
- SCHEMA-03: content.add now writes DWN file-catalog/v1 message alongside the existing catalog entry. File metadata queryable via dwn.query-messages. - SCHEMA-04: federation.join now writes DWN federation/v1 membership message. Federation relationships queryable via DWN protocol filter. Both integrations are non-fatal on DWN errors (existing flows unaffected). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
267a7c7202
commit
42f0c2521a
@@ -1,8 +1,11 @@
|
||||
use super::RpcHandler;
|
||||
use crate::content_server::{self, AccessControl, Availability, ContentItem};
|
||||
use crate::network::dwn_store::DwnStore;
|
||||
use anyhow::{Context, Result};
|
||||
use tracing::debug;
|
||||
|
||||
const FILE_CATALOG_PROTOCOL: &str = "https://archipelago.dev/protocols/file-catalog/v1";
|
||||
|
||||
impl RpcHandler {
|
||||
/// List content I'm sharing.
|
||||
pub(super) async fn handle_content_list_mine(
|
||||
@@ -49,6 +52,36 @@ impl RpcHandler {
|
||||
}
|
||||
|
||||
content_server::add_item(&self.config.data_dir, item.clone()).await?;
|
||||
|
||||
// Also store as DWN message for interoperable file catalog
|
||||
if let Ok(store) = DwnStore::new(&self.config.data_dir).await {
|
||||
let did = crate::identity::did_key_from_pubkey_hex(
|
||||
&self.state_manager.get_snapshot().await.0.server_info.pubkey,
|
||||
)
|
||||
.unwrap_or_default();
|
||||
let dwn_data = serde_json::json!({
|
||||
"id": item.id,
|
||||
"title": item.filename,
|
||||
"description": item.description,
|
||||
"content_type": item.mime_type,
|
||||
"size_bytes": item.size_bytes,
|
||||
"access": format!("{:?}", item.access).to_lowercase(),
|
||||
"created_at": item.added_at,
|
||||
});
|
||||
if let Err(e) = store
|
||||
.write_message(
|
||||
&did,
|
||||
Some(FILE_CATALOG_PROTOCOL),
|
||||
Some("https://archipelago.dev/schemas/file-entry/v1"),
|
||||
Some("application/json"),
|
||||
Some(dwn_data),
|
||||
)
|
||||
.await
|
||||
{
|
||||
debug!("DWN file catalog write (non-fatal): {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(serde_json::json!({ "item": item }))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user