add: open graph tags for posts and notes
This commit is contained in:
parent
af6fbdf04e
commit
0c509b7001
4 changed files with 97 additions and 20 deletions
|
@ -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
|
||||
|
|
|
@ -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 %}")
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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(())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue