about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2024-08-23 18:24:31 +0300
committerVika <vika@fireburn.ru>2024-08-23 18:24:31 +0300
commit22217993d1a0cba4d419ddf2867e1751df9248bc (patch)
treec1bb669e74036dbdcdb3bebbe6fd77d2a3edde0a /src
parentb96e44f3526a6da09b5fd09617802190fa8fc134 (diff)
downloadkittybox-22217993d1a0cba4d419ddf2867e1751df9248bc.tar.zst
Fix private posts with no defined audience not being shown in feeds
Diffstat (limited to 'src')
-rw-r--r--src/database/postgres/mod.rs11
-rw-r--r--src/frontend/mod.rs6
2 files changed, 10 insertions, 7 deletions
diff --git a/src/database/postgres/mod.rs b/src/database/postgres/mod.rs
index 3aef08e..1780672 100644
--- a/src/database/postgres/mod.rs
+++ b/src/database/postgres/mod.rs
@@ -373,9 +373,12 @@ WHERE
         )
         OR
         (
-            $3 != null AND (
-                mf2['properties']['audience'] ? $3
-                OR mf2['properties']['author'] ? $3
+            $3 IS NOT NULL AND (
+                (NOT (mf2['properties'] ? 'audience'))
+                OR
+                (mf2['properties']['audience'] ? $3)
+                OR
+                (mf2['properties']['author'] ? $3)
             )
         )
     )
@@ -385,7 +388,7 @@ LIMIT $2"
         )
             .bind(url)
             .bind(limit as i64)
-            .bind(user.map(url::Url::to_string))
+            .bind(user.map(url::Url::as_str))
             .bind(cursor)
             .fetch_all(&mut *txn)
             .await
diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs
index c4a86b4..81a03ed 100644
--- a/src/frontend/mod.rs
+++ b/src/frontend/mod.rs
@@ -245,9 +245,9 @@ pub async fn homepage<D: Storage>(
     let hcard_url: url::Url = format!("https://{}/", host).parse().unwrap();
     let feed_path = format!("https://{}/feeds/main", host);
 
-    let user = session.as_ref().map(|s| &s.0.me);
+    let user = session.as_deref().map(|s| &s.me);
     match tokio::try_join!(
-        get_post_from_database(&db, &hcard_url.as_str(), None, user),
+        get_post_from_database(&db, hcard_url.as_str(), None, user),
         get_post_from_database(&db, &feed_path, query.after, user)
     ) {
         Ok(((hcard, _), (hfeed, cursor))) => {
@@ -339,7 +339,7 @@ pub async fn catchall<D: Storage>(
     session: Option<crate::Session>,
     uri: Uri,
 ) -> impl IntoResponse {
-    let user: Option<&url::Url> = session.as_deref().map(|p| &p.me); // TODO authentication
+    let user: Option<&url::Url> = session.as_deref().map(|p| &p.me);
     let host = url::Url::parse(&format!("https://{}/", host)).unwrap();
     let path = host
         .clone()