add: ability to disable reactions on posts

This commit is contained in:
trisua 2025-04-13 00:42:10 -04:00
parent 98d17204d7
commit 09ef0fc301
3 changed files with 21 additions and 6 deletions

View file

@ -134,8 +134,11 @@
"checkbox", "checkbox",
], ],
[ [
["reposts_enabled", "Allow people to repost your post"], [
"{{ post.context.reposts_enabled }}", "reactions_enabled",
"Allow people to like/dislike your post",
],
"{{ post.context.reactions_enabled }}",
"checkbox", "checkbox",
], ],
[ [

View file

@ -235,8 +235,10 @@ and show_community and community.id != config.town_square or question %}
hook-arg:id="{{ post.id }}" hook-arg:id="{{ post.id }}"
> >
<!-- prettier-ignore --> <!-- prettier-ignore -->
{% if post.content|length > 0 %} {% if post.context.reactions_enabled %}
{{ components::likes(id=post.id, asset_type="Post", likes=post.likes, dislikes=post.dislikes) }} {% if post.content|length > 0 %}
{{ components::likes(id=post.id, asset_type="Post", likes=post.likes, dislikes=post.dislikes) }}
{% endif %}
{% endif %} {% endif %}
{% if post.context.repost and post.context.repost.reposting %} {% if post.context.repost and post.context.repost.reposting %}
@ -617,7 +619,10 @@ show_community=true, secondary=false) -%}
</span> </span>
{% if question.community > 0 and show_community %} {% if question.community > 0 and show_community %}
<a href="/api/v1/communities/find/{{ question.community }}"> <a
href="/api/v1/communities/find/{{ question.community }}"
class="flex items-center"
>
{{ components::community_avatar(id=question.community, {{ components::community_avatar(id=question.community,
size="24px") }} size="24px") }}
</a> </a>

View file

@ -176,6 +176,8 @@ pub struct PostContext {
/// The ID of the question this post is answering. /// The ID of the question this post is answering.
#[serde(default)] #[serde(default)]
pub answering: usize, pub answering: usize,
#[serde(default = "default_reactions_enabled")]
pub reactions_enabled: bool,
} }
fn default_comments_enabled() -> bool { fn default_comments_enabled() -> bool {
@ -186,17 +188,22 @@ fn default_reposts_enabled() -> bool {
true true
} }
fn default_reactions_enabled() -> bool {
true
}
impl Default for PostContext { impl Default for PostContext {
fn default() -> Self { fn default() -> Self {
Self { Self {
comments_enabled: default_comments_enabled(), comments_enabled: default_comments_enabled(),
reposts_enabled: true, reposts_enabled: default_reposts_enabled(),
is_pinned: false, is_pinned: false,
is_profile_pinned: false, is_profile_pinned: false,
edited: 0, edited: 0,
is_nsfw: false, is_nsfw: false,
repost: None, repost: None,
answering: 0, answering: 0,
reactions_enabled: default_reactions_enabled(),
} }
} }
} }