Parakeet is a Rust-based Bluesky AppServer aiming to implement most of the functionality required to support the Bluesky client
appview atproto bluesky rust appserver

consts for threadgate rules

mia.omg.lol c0f3cd76 a3338668

verified
+18 -11
+9 -7
consumer/src/db/gates.rs
··· 1 1 use super::{PgExecResult, PgResult}; 2 + use crate::indexer::records::{ 3 + THREADGATE_RULE_FOLLOWER, THREADGATE_RULE_FOLLOWING, THREADGATE_RULE_LIST, 4 + THREADGATE_RULE_MENTION, 5 + }; 2 6 use chrono::prelude::*; 3 7 use chrono::{DateTime, Utc}; 4 8 use deadpool_postgres::GenericClient; ··· 36 40 37 41 let allow: HashSet<String> = HashSet::from_iter(allow); 38 42 39 - if allow.contains("app.bsky.feed.threadgate#followerRule") 40 - || allow.contains("app.bsky.feed.threadgate#followingRule") 41 - { 43 + if allow.contains(THREADGATE_RULE_FOLLOWER) || allow.contains(THREADGATE_RULE_FOLLOWING) { 42 44 let profile_state: Option<(bool, bool)> = conn 43 45 .query_opt( 44 46 "SELECT following IS NOT NULL, followed IS NOT NULL FROM profile_states WHERE did=$1 AND subject=$2", ··· 48 50 .map(|v| (v.get(0), v.get(1))); 49 51 50 52 if let Some((following, followed)) = profile_state { 51 - if allow.contains("app.bsky.feed.threadgate#followerRule") && followed { 53 + if allow.contains(THREADGATE_RULE_FOLLOWER) && followed { 52 54 return Ok(false); 53 55 } 54 56 55 - if allow.contains("app.bsky.feed.threadgate#followingRule") && following { 57 + if allow.contains(THREADGATE_RULE_FOLLOWING) && following { 56 58 return Ok(false); 57 59 } 58 60 } 59 61 } 60 62 61 63 // check mentions 62 - if allow.contains("app.bsky.feed.threadgate#mentionRule") { 64 + if allow.contains(THREADGATE_RULE_MENTION) { 63 65 let mentions: Vec<String> = conn 64 66 .query_opt("SELECT mentions FROM posts WHERE at_uri=$1", &[&root]) 65 67 .await? ··· 71 73 } 72 74 } 73 75 74 - if allow.contains("app.bsky.feed.threadgate#listRule") { 76 + if allow.contains(THREADGATE_RULE_LIST) { 75 77 if allow_lists.is_empty() { 76 78 return Ok(true); 77 79 }
+9 -4
consumer/src/indexer/records.rs
··· 272 272 pub hidden_replies: Vec<String>, 273 273 } 274 274 275 + pub const THREADGATE_RULE_MENTION: &str = "app.bsky.feed.threadgate#mentionRule"; 276 + pub const THREADGATE_RULE_FOLLOWER: &str = "app.bsky.feed.threadgate#followerRule"; 277 + pub const THREADGATE_RULE_FOLLOWING: &str = "app.bsky.feed.threadgate#followingRule"; 278 + pub const THREADGATE_RULE_LIST: &str = "app.bsky.feed.threadgate#listRule"; 279 + 275 280 #[derive(Debug, Deserialize, Serialize)] 276 281 #[serde(tag = "$type")] 277 282 pub enum ThreadgateRule { ··· 288 293 impl ThreadgateRule { 289 294 pub fn as_str(&self) -> &'static str { 290 295 match self { 291 - ThreadgateRule::Mention => "app.bsky.feed.threadgate#mentionRule", 292 - ThreadgateRule::Follower => "app.bsky.feed.threadgate#followerRule", 293 - ThreadgateRule::Following => "app.bsky.feed.threadgate#followingRule", 294 - ThreadgateRule::List { .. } => "app.bsky.feed.threadgate#listRule", 296 + ThreadgateRule::Mention => THREADGATE_RULE_MENTION, 297 + ThreadgateRule::Follower => THREADGATE_RULE_FOLLOWER, 298 + ThreadgateRule::Following => THREADGATE_RULE_FOLLOWING, 299 + ThreadgateRule::List { .. } => THREADGATE_RULE_LIST, 295 300 } 296 301 } 297 302 }