about summary refs log tree commit diff
path: root/src/database/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/database/mod.rs')
-rw-r--r--src/database/mod.rs34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/database/mod.rs b/src/database/mod.rs
index a6a3b46..f48b4a9 100644
--- a/src/database/mod.rs
+++ b/src/database/mod.rs
@@ -227,7 +227,7 @@ pub trait Storage: std::fmt::Debug + Clone + Send + Sync {
     /// Save a post to the database as an MF2-JSON structure.
     ///
     /// Note that the `post` object MUST have `post["properties"]["uid"][0]` defined.
-    async fn put_post(&self, post: &'_ serde_json::Value, user: &'_ str) -> Result<()>;
+    async fn put_post(&self, post: &'_ serde_json::Value, user: &url::Url) -> Result<()>;
 
     /// Add post to feed. Some database implementations might have optimized ways to do this.
     #[tracing::instrument(skip(self))]
@@ -258,7 +258,7 @@ pub trait Storage: std::fmt::Debug + Clone + Send + Sync {
 
     /// Get a list of channels available for the user represented by
     /// the `user` domain to write to.
-    async fn get_channels(&self, user: &'_ str) -> Result<Vec<MicropubChannel>>;
+    async fn get_channels(&self, user: &url::Url) -> Result<Vec<MicropubChannel>>;
 
     /// Fetch a feed at `url` and return an h-feed object containing
     /// `limit` posts after a post by url `after`, filtering the content
@@ -279,9 +279,9 @@ pub trait Storage: std::fmt::Debug + Clone + Send + Sync {
     async fn read_feed_with_limit(
         &self,
         url: &'_ str,
-        after: &'_ Option<String>,
+        after: Option<&str>,
         limit: usize,
-        user: &'_ Option<String>,
+        user: Option<&url::Url>,
     ) -> Result<Option<serde_json::Value>>;
 
     /// Fetch a feed at `url` and return an h-feed object containing
@@ -307,17 +307,17 @@ pub trait Storage: std::fmt::Debug + Clone + Send + Sync {
         url: &'_ str,
         cursor: Option<&'_ str>,
         limit: usize,
-        user: Option<&'_ str>
+        user: Option<&url::Url>
     ) -> Result<Option<(serde_json::Value, Option<String>)>>;
 
     /// Deletes a post from the database irreversibly. Must be idempotent.
     async fn delete_post(&self, url: &'_ str) -> Result<()>;
 
     /// Gets a setting from the setting store and passes the result.
-    async fn get_setting<S: Setting<'a>, 'a>(&'_ self, user: &'_ str) -> Result<S>;
+    async fn get_setting<S: Setting<'a>, 'a>(&'_ self, user: &url::Url) -> Result<S>;
 
     /// Commits a setting to the setting store.
-    async fn set_setting<S: Setting<'a> + 'a, 'a>(&self, user: &'a str, value: S::Data) -> Result<()>;
+    async fn set_setting<S: Setting<'a> + 'a, 'a>(&self, user: &'a url::Url, value: S::Data) -> Result<()>;
 
     /// Add (or update) a webmention on a certian post.
     ///
@@ -359,7 +359,7 @@ mod tests {
 
         // Reading and writing
         backend
-            .put_post(&post, "fireburn.ru")
+            .put_post(&post, &"https://fireburn.ru/".parse().unwrap())
             .await
             .unwrap();
         if let Some(returned_post) = backend.get_post(&key).await.unwrap() {
@@ -423,7 +423,7 @@ mod tests {
 
         // Reading and writing
         backend
-            .put_post(&post, "fireburn.ru")
+            .put_post(&post, &"https://fireburn.ru/".parse().unwrap())
             .await
             .unwrap();
 
@@ -482,10 +482,10 @@ mod tests {
             "children": []
         });
         backend
-            .put_post(&feed, "fireburn.ru")
+            .put_post(&feed, &"https://fireburn.ru/".parse().unwrap())
             .await
             .unwrap();
-        let chans = backend.get_channels("fireburn.ru").await.unwrap();
+        let chans = backend.get_channels(&"https://fireburn.ru/".parse().unwrap()).await.unwrap();
         assert_eq!(chans.len(), 1);
         assert_eq!(
             chans[0],
@@ -499,14 +499,14 @@ mod tests {
     async fn test_settings<Backend: Storage>(backend: Backend) {
         backend
             .set_setting::<settings::SiteName>(
-                "https://fireburn.ru/",
+                &"https://fireburn.ru/".parse().unwrap(),
                 "Vika's Hideout".to_owned()
             )
             .await
             .unwrap();
         assert_eq!(
             backend
-            .get_setting::<settings::SiteName>("https://fireburn.ru/")
+            .get_setting::<settings::SiteName>(&"https://fireburn.ru/".parse().unwrap())
             .await
             .unwrap()
             .as_ref(),
@@ -594,13 +594,13 @@ mod tests {
         let key = feed["properties"]["uid"][0].as_str().unwrap();
 
         backend
-            .put_post(&feed, "fireburn.ru")
+            .put_post(&feed, &"https://fireburn.ru/".parse().unwrap())
             .await
             .unwrap();
 
         for (i, post) in posts.iter().rev().enumerate() {
             backend
-                .put_post(post, "fireburn.ru")
+                .put_post(post, &"https://fireburn.ru/".parse().unwrap())
                 .await
                 .unwrap();
             backend.add_to_feed(key, post["properties"]["uid"][0].as_str().unwrap()).await.unwrap();
@@ -699,7 +699,7 @@ mod tests {
     async fn test_webmention_addition<Backend: Storage>(db: Backend) {
         let post = gen_random_post("fireburn.ru");
 
-        db.put_post(&post, "fireburn.ru").await.unwrap();
+        db.put_post(&post, &"https://fireburn.ru/".parse().unwrap()).await.unwrap();
         const TYPE: MentionType = MentionType::Reply;
 
         let target = post["properties"]["uid"][0].as_str().unwrap();
@@ -732,7 +732,7 @@ mod tests {
 
             post
         };
-        db.put_post(&post, "fireburn.ru").await.unwrap();
+        db.put_post(&post, &"https://fireburn.ru/".parse().unwrap()).await.unwrap();
 
         for i in post["properties"]["url"].as_array().unwrap() {
             let (read_post, _) = db.read_feed_with_cursor(i.as_str().unwrap(), None, 20, None).await.unwrap().unwrap();