diff --git a/crates/app/src/public/html/journals/app.lisp b/crates/app/src/public/html/journals/app.lisp index 697c466..cae5082 100644 --- a/crates/app/src/public/html/journals/app.lisp +++ b/crates/app/src/public/html/journals/app.lisp @@ -1,5 +1,43 @@ (text "{% extends \"root.html\" %} {% block head %}") (text "{% if journal -%}") (title (text "{{ journal.title }}")) (text "{% else %}") (title (text "Journals - {{ config.name }}")) (text "{%- endif %}") + +(text "{% if note and journal and owner -%}") +(meta + ("name" "og:title") + ("content" "{{ note.title }}")) + +(meta + ("name" "description") + ("content" "View this note from the {{ journal.title }} journal on {{ config.name }}!")) + +(meta + ("name" "og:description") + ("content" "View this note from the {{ journal.title }} journal on {{ config.name }}!")) + +(meta + ("property" "og:type") + ("content" "website")) + +(meta + ("name" "og:image") + ("content" "{{ config.host|safe }}/api/v1/auth/user/{{ owner.username }}/avatar?selector_type=username")) + +(meta + ("name" "twitter:image") + ("content" "{{ config.host|safe }}/api/v1/auth/user/{{ owner.username }}/avatar?selector_type=usernamev")) + +(meta + ("name" "twitter:card") + ("content" "summary")) + +(meta + ("name" "twitter:title") + ("content" "{{ note.title }}")) + +(meta + ("name" "twitter:description") + ("content" "View this note from the {{ journal.title }} journal on {{ config.name }}!")) +(text "{%- endif %}") (link ("rel" "stylesheet") ("data-turbo-temporary" "true") ("href" "/css/chats.css?v=tetratto-{{ random_cache_breaker }}")) (style diff --git a/crates/app/src/public/html/macros.lisp b/crates/app/src/public/html/macros.lisp index 18820ce..7691ee9 100644 --- a/crates/app/src/public/html/macros.lisp +++ b/crates/app/src/public/html/macros.lisp @@ -48,7 +48,7 @@ (a ("href" "/requests") ("class" "button {% if selected == 'requests' -%}active{%- endif %}") - ("title" "Chats") + ("title" "Requests") (icon (text "inbox")) (span ("class" "notification tr {% if user.request_count <= 0 -%}hidden{%- endif %}") @@ -58,7 +58,7 @@ (a ("href" "/notifs") ("class" "button {% if selected == 'notifications' -%}active{%- endif %}") - ("title" "Chats") + ("title" "Notifications") (icon (text "bell")) (span ("class" "notification tr {% if user.notification_count <= 0 -%}hidden{%- endif %}") diff --git a/crates/app/src/public/html/post/post.lisp b/crates/app/src/public/html/post/post.lisp index 22f64e9..fc40c2d 100644 --- a/crates/app/src/public/html/post/post.lisp +++ b/crates/app/src/public/html/post/post.lisp @@ -2,6 +2,41 @@ (title (text "Post - {{ config.name }}")) +(meta + ("name" "og:title") + ("content" "{% if owner.settings.display_name -%} {{ owner.settings.display_name }} {%- else -%} {{ owner.username }} {%- endif %}'s post")) + +(meta + ("name" "description") + ("content" "View this post from @{{ owner.username }} on {{ config.name }}!")) + +(meta + ("name" "og:description") + ("content" "View this post from @{{ owner.username }} on {{ config.name }}!")) + +(meta + ("property" "og:type") + ("content" "website")) + +(meta + ("name" "og:image") + ("content" "{{ config.host|safe }}/api/v1/auth/user/{{ owner.username }}/avatar?selector_type=username")) + +(meta + ("name" "twitter:image") + ("content" "{{ config.host|safe }}/api/v1/auth/user/{{ owner.username }}/avatar?selector_type=usernamev")) + +(meta + ("name" "twitter:card") + ("content" "summary")) + +(meta + ("name" "twitter:title") + ("content" "{% if owner.settings.display_name -%} {{ owner.settings.display_name }} {%- else -%} {{ owner.username }} {%- endif %}'s post")) + +(meta + ("name" "twitter:description") + ("content" "View this post from @{{ owner.username }} on {{ config.name }}!")) (text "{% endblock %} {% block body %} {{ macros::nav() }}") (main ("class" "flex flex-col gap-2") diff --git a/crates/core/src/database/notifications.rs b/crates/core/src/database/notifications.rs index 620434b..080e182 100644 --- a/crates/core/src/database/notifications.rs +++ b/crates/core/src/database/notifications.rs @@ -194,34 +194,38 @@ impl DataManager { } pub async fn delete_all_notifications(&self, user: &User) -> Result<()> { - let notifications = self.get_notifications_by_owner(user.id).await?; + let conn = match self.0.connect().await { + Ok(c) => c, + Err(e) => return Err(Error::DatabaseConnection(e.to_string())), + }; - for notification in notifications { - if user.id != notification.owner - && !user.permissions.check(FinePermission::MANAGE_NOTIFICATIONS) - { - return Err(Error::NotAllowed); - } + let res = execute!( + &conn, + "DELETE FROM notifications WHERE owner = $1", + &[&(user.id as i64)] + ); - self.delete_notification(notification.id, user).await? + if let Err(e) = res { + return Err(Error::DatabaseError(e.to_string())); } - self.update_user_notification_count(user.id, 0).await?; - Ok(()) } pub async fn delete_all_notifications_by_tag(&self, user: &User, tag: &str) -> Result<()> { - let notifications = self.get_notifications_by_tag(tag).await?; + let conn = match self.0.connect().await { + Ok(c) => c, + Err(e) => return Err(Error::DatabaseConnection(e.to_string())), + }; - for notification in notifications { - if user.id != notification.owner - && !user.permissions.check(FinePermission::MANAGE_NOTIFICATIONS) - { - return Err(Error::NotAllowed); - } + let res = execute!( + &conn, + "DELETE FROM notifications WHERE owner = $1 AND tag = $2", + params![&(user.id as i64), tag] + ); - self.delete_notification(notification.id, user).await? + if let Err(e) = res { + return Err(Error::DatabaseError(e.to_string())); } Ok(())