lemmynsfw-changes
Felix Ableitner 2024-01-23 11:58:04 +01:00
parent d8aa6b3350
commit d9fc981b06
7 changed files with 18 additions and 6 deletions

View File

@ -132,8 +132,8 @@ pub async fn check_vote_permission(
) -> LemmyResult<()> { ) -> LemmyResult<()> {
let local_site = LocalSite::read(&mut context.pool()).await?; let local_site = LocalSite::read(&mut context.pool()).await?;
let community = Community::read(&mut context.pool(), community_id).await?; let community = Community::read(&mut context.pool(), community_id).await?;
let score = vote_type.map(|v| v.into()).unwrap_or(0); let score = vote_type.map(std::convert::Into::into).unwrap_or(0);
lemmy_api_common::utils::check_vote_permission(score, &local_site, &person, &community, &context) lemmy_api_common::utils::check_vote_permission(score, &local_site, person, &community, context)
.await?; .await?;
Ok(()) Ok(())
} }

View File

@ -434,6 +434,7 @@ mod tests {
hidden: false, hidden: false,
posting_restricted_to_mods: false, posting_restricted_to_mods: false,
instance_id: inserted_instance.id, instance_id: inserted_instance.id,
only_followers_can_vote: false,
}; };
let community_follower_form = CommunityFollowerForm { let community_follower_form = CommunityFollowerForm {

View File

@ -379,6 +379,7 @@ mod tests {
moderators_url: inserted_community.moderators_url, moderators_url: inserted_community.moderators_url,
featured_url: inserted_community.featured_url, featured_url: inserted_community.featured_url,
instance_id: inserted_instance.id, instance_id: inserted_instance.id,
only_followers_can_vote: inserted_community.only_followers_can_vote,
}, },
creator: Person { creator: Person {
id: inserted_jessica.id, id: inserted_jessica.id,

View File

@ -1041,6 +1041,7 @@ mod tests {
shared_inbox_url: data.inserted_community.shared_inbox_url.clone(), shared_inbox_url: data.inserted_community.shared_inbox_url.clone(),
moderators_url: data.inserted_community.moderators_url.clone(), moderators_url: data.inserted_community.moderators_url.clone(),
featured_url: data.inserted_community.featured_url.clone(), featured_url: data.inserted_community.featured_url.clone(),
only_followers_can_vote: data.inserted_community.only_followers_can_vote,
}, },
counts: CommentAggregates { counts: CommentAggregates {
comment_id: data.inserted_comment_0.id, comment_id: data.inserted_comment_0.id,

View File

@ -1539,6 +1539,7 @@ mod tests {
shared_inbox_url: inserted_community.shared_inbox_url.clone(), shared_inbox_url: inserted_community.shared_inbox_url.clone(),
moderators_url: inserted_community.moderators_url.clone(), moderators_url: inserted_community.moderators_url.clone(),
featured_url: inserted_community.featured_url.clone(), featured_url: inserted_community.featured_url.clone(),
only_followers_can_vote: inserted_community.only_followers_can_vote,
}, },
counts: PostAggregates { counts: PostAggregates {
post_id: inserted_post.id, post_id: inserted_post.id,

View File

@ -1,2 +1,6 @@
alter table local_site drop column content_warning; ALTER TABLE local_site
alter table community drop column only_followers_can_vote; DROP COLUMN content_warning;
ALTER TABLE community
DROP COLUMN only_followers_can_vote;

View File

@ -1,2 +1,6 @@
alter table local_site add column content_warning text; ALTER TABLE local_site
alter table community add column only_followers_can_vote boolean not null default false; ADD COLUMN content_warning text;
ALTER TABLE community
ADD COLUMN only_followers_can_vote boolean NOT NULL DEFAULT FALSE;