aboutsummaryrefslogtreecommitdiff
path: root/aero-proto
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-05-29 08:47:56 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-05-29 08:47:56 +0200
commitf9fab60e5ee77c0cf57744e39b5685902189a38b (patch)
tree8434d66f7b38658edb4db7648527930f3f26aab0 /aero-proto
parenta2f5b451bd32780d60be69c6412cb351a54b765b (diff)
downloadaerogramme-f9fab60e5ee77c0cf57744e39b5685902189a38b.tar.gz
aerogramme-f9fab60e5ee77c0cf57744e39b5685902189a38b.zip
test report sync-collection
Diffstat (limited to 'aero-proto')
-rw-r--r--aero-proto/src/dav/controller.rs2
-rw-r--r--aero-proto/src/dav/resource.rs36
2 files changed, 36 insertions, 2 deletions
diff --git a/aero-proto/src/dav/controller.rs b/aero-proto/src/dav/controller.rs
index 7e1f416..76dd15d 100644
--- a/aero-proto/src/dav/controller.rs
+++ b/aero-proto/src/dav/controller.rs
@@ -184,7 +184,7 @@ impl Controller {
},
};
extension = Some(realization::Multistatus::Sync(sync::Multistatus {
- sync_token: sync::SyncToken(new_token.to_string()),
+ sync_token: sync::SyncToken(format!("{}{}", BASE_TOKEN_URI, new_token)),
}));
}
_ => {
diff --git a/aero-proto/src/dav/resource.rs b/aero-proto/src/dav/resource.rs
index 297a1c1..b6c0ed5 100644
--- a/aero-proto/src/dav/resource.rs
+++ b/aero-proto/src/dav/resource.rs
@@ -21,6 +21,16 @@ use aero_dav::versioningtypes as vers;
use super::node::PropertyStream;
use crate::dav::node::{Content, DavNode, PutPolicy};
+/// Why "https://aerogramme.0"?
+/// Because tokens must be valid URI.
+/// And numeric TLD are ~mostly valid in URI (check the .42 TLD experience)
+/// and at the same time, they are not used sold by the ICANN and there is no plan to use them.
+/// So I am sure that the URL remains invalid, avoiding leaking requests to an hardcoded URL in the
+/// future.
+/// The best option would be to make it configurable ofc, so someone can put a domain name
+/// that they control, it would probably improve compatibility (maybe some WebDAV spec tells us
+/// how to handle/resolve this URI but I am not aware of that...). But that's not the plan for
+/// now. So here we are: https://aerogramme.0.
pub const BASE_TOKEN_URI: &str = "https://aerogramme.0/sync/";
#[derive(Clone)]
@@ -575,7 +585,31 @@ impl DavNode for CalendarNode {
let col = self.col.clone();
let calname = self.calname.clone();
async move {
- let sync_token = sync_token.unwrap();
+ let sync_token = match sync_token {
+ Some(v) => v,
+ None => {
+ let token = col
+ .token()
+ .await
+ .or(Err(std::io::Error::from(std::io::ErrorKind::Interrupted)))?;
+ let ok_nodes = col
+ .dag()
+ .await
+ .idx_by_filename
+ .iter()
+ .map(|(filename, blob_id)| {
+ Box::new(EventNode {
+ col: col.clone(),
+ calname: calname.clone(),
+ filename: filename.to_string(),
+ blob_id: *blob_id,
+ }) as Box<dyn DavNode>
+ })
+ .collect();
+
+ return Ok((token, ok_nodes, vec![]));
+ }
+ };
let (new_token, listed_changes) = match col.diff(sync_token).await {
Ok(v) => v,
Err(e) => {