New protected communitites feature
This commit is contained in:
parent
2069345e9e
commit
080b0bf4d8
3 changed files with 24 additions and 4 deletions
src/bot
|
@ -236,7 +236,8 @@ async fn handle_series(
|
|||
|
||||
let post_id = lemmy.post(post_data).await?;
|
||||
|
||||
if post_series_config.pin_settings.pin_new_post_community {
|
||||
let read = data.read().await;
|
||||
if post_series_config.pin_settings.pin_new_post_community && !read.config.protected_communities.contains(&post_series_config.name) {
|
||||
let pinned_posts = lemmy.get_community_pinned(community_id).await?;
|
||||
if !pinned_posts.is_empty() {
|
||||
let community_pinned_post = &pinned_posts[0];
|
||||
|
@ -244,17 +245,33 @@ async fn handle_series(
|
|||
}
|
||||
lemmy.pin(post_id, PostFeatureType::Community).await?;
|
||||
}
|
||||
else if read.config.protected_communities.contains(&post_series_config.name) {
|
||||
let message = Message::Warning(format!("Community '{}' for Series '{}' is protected. Is this intended?", &post_series_config.name, series.slug));
|
||||
if !read.messages.contains(&message) {
|
||||
drop(read);
|
||||
let mut write = data.write().await;
|
||||
write.messages.push(message);
|
||||
};
|
||||
}
|
||||
|
||||
let read = data.read().await;
|
||||
if post_series_config.pin_settings.pin_new_post_local {
|
||||
let pinned_posts = lemmy.get_local_pinned().await?;
|
||||
if !pinned_posts.is_empty() {
|
||||
let community_pinned_post = &pinned_posts[0];
|
||||
lemmy.unpin(community_pinned_post.post.id, PostFeatureType::Local).await?;
|
||||
for pinned_post in pinned_posts {
|
||||
if read.config.protected_communities.contains(&pinned_post.community.name) {
|
||||
continue
|
||||
}
|
||||
else {
|
||||
let community_pinned_post = &pinned_post;
|
||||
lemmy.unpin(community_pinned_post.post.id, PostFeatureType::Local).await?;
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
lemmy.pin(post_id, PostFeatureType::Local).await?;
|
||||
}
|
||||
|
||||
let read = data.read().await;
|
||||
let mut series_history = read.post_history.get_series(series.slug.as_str());
|
||||
let mut part_history = series_history.get_part(post_part_info.as_string().as_str());
|
||||
drop(read);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue