diff --git a/src/bot/mod.rs b/src/bot/mod.rs index 8c1a5fa..046de5f 100644 --- a/src/bot/mod.rs +++ b/src/bot/mod.rs @@ -243,22 +243,23 @@ async fn handle_series( let post_id = lemmy.post(post_data).await?; - 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]; - lemmy.unpin(community_pinned_post.post.id, PostFeatureType::Community).await?; + { + 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]; + lemmy.unpin(community_pinned_post.post.id, PostFeatureType::Community).await?; + } + 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); + } } - 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;