diff options
author | Vika <vika@fireburn.ru> | 2023-06-22 21:35:22 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2023-06-22 21:35:22 +0300 |
commit | 858c0ddd9cc36af0acc72efb1ff1bdc1d8e28b0a (patch) | |
tree | 5b46bcc88e37fa0e23fea4f49c0242ad21662bca /kittybox-rs/src/micropub | |
parent | d61e1f6a8e5ad5b7c14b1f9ab3101496f3f9ea00 (diff) | |
download | kittybox-858c0ddd9cc36af0acc72efb1ff1bdc1d8e28b0a.tar.zst |
database: use domains instead of authorities as owner key
This allows disregarding http/https comparisons and simplifies some database designs.
Diffstat (limited to 'kittybox-rs/src/micropub')
-rw-r--r-- | kittybox-rs/src/micropub/mod.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/kittybox-rs/src/micropub/mod.rs b/kittybox-rs/src/micropub/mod.rs index ee4d334..5c297f9 100644 --- a/kittybox-rs/src/micropub/mod.rs +++ b/kittybox-rs/src/micropub/mod.rs @@ -262,9 +262,15 @@ pub(crate) async fn _post<D: 'static + Storage>( error_description: "UID clash was detected, operation aborted.".to_owned(), }); } - + let user_domain = format!( + "{}{}", + user.me.host_str().unwrap(), + user.me.port() + .map(|port| format!(":{}", port)) + .unwrap_or_default() + ); // Save the post - db.put_post(&mf2, user.me.as_str()).await?; + db.put_post(&mf2, &user_domain).await?; let mut channels = mf2["properties"]["channel"] .as_array() @@ -521,7 +527,13 @@ pub(crate) async fn query<D: Storage, A: AuthBackend>( .into_response(); } - + let user_domain = format!( + "{}{}", + user.me.host_str().unwrap(), + user.me.port() + .map(|port| format!(":{}", port)) + .unwrap_or_default() + ); match query.q { QueryType::Config => { let channels: Vec<MicropubChannel> = match db.get_channels(user.me.as_str()).await { @@ -580,7 +592,7 @@ pub(crate) async fn query<D: Storage, A: AuthBackend>( } } } - QueryType::Channel => match db.get_channels(user.me.as_str()).await { + QueryType::Channel => match db.get_channels(&user_domain).await { Ok(chans) => axum::response::Json(json!({ "channels": chans })).into_response(), Err(err) => MicropubError::new( ErrorType::InternalServerError, |