tangled
alpha
login
or
join now
parakeet.at
/
parakeet
63
fork
atom
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
63
fork
atom
overview
issues
12
pulls
pipelines
fix: threadgate models
mia.omg.lol
5 months ago
e9a26f5d
8722e61a
verified
This commit was signed with the committer's
known signature
.
mia.omg.lol
SSH Key Fingerprint:
SHA256:eb+NhC0QEl+XKRuFP/97oH6LEz0TXTKPXGDIAI5y7CQ=
+24
-14
3 changed files
expand all
collapse all
unified
split
parakeet
src
hydration
list.rs
posts.rs
parakeet-db
src
models.rs
+2
-2
parakeet-db/src/models.rs
···
250
250
pub post_uri: String,
251
251
252
252
pub hidden_replies: Vec<Option<String>>,
253
253
-
pub allow: Vec<Option<String>>,
254
254
-
pub allowed_lists: Vec<Option<String>>,
253
253
+
pub allow: Option<Vec<Option<String>>>,
254
254
+
pub allowed_lists: Option<Vec<Option<String>>>,
255
255
256
256
pub record: serde_json::Value,
257
257
+8
parakeet/src/hydration/list.rs
···
78
78
}
79
79
80
80
pub async fn hydrate_lists_basic(&self, lists: Vec<String>) -> HashMap<String, ListViewBasic> {
81
81
+
if lists.is_empty() {
82
82
+
return HashMap::new();
83
83
+
}
84
84
+
81
85
let labels = self.get_label_many(&lists).await;
82
86
let viewers = self.get_list_viewer_states(&lists).await;
83
87
let lists = self.loaders.list.load_many(lists).await;
···
103
107
}
104
108
105
109
pub async fn hydrate_lists(&self, lists: Vec<String>) -> HashMap<String, ListView> {
110
110
+
if lists.is_empty() {
111
111
+
return HashMap::new();
112
112
+
}
113
113
+
106
114
let labels = self.get_label_many(&lists).await;
107
115
let viewers = self.get_list_viewer_states(&lists).await;
108
116
let lists = self.loaders.list.load_many(lists).await;
+14
-12
parakeet/src/hydration/posts.rs
···
83
83
) -> Option<ThreadgateView> {
84
84
let threadgate = threadgate?;
85
85
86
86
-
let lists = threadgate
87
87
-
.allowed_lists
88
88
-
.iter()
89
89
-
.flatten()
90
90
-
.cloned()
91
91
-
.collect::<Vec<_>>();
86
86
+
let lists = match threadgate.allowed_lists.as_ref() {
87
87
+
Some(allowed_lists) => allowed_lists.iter().flatten().cloned().collect(),
88
88
+
None => Vec::new(),
89
89
+
};
92
90
let lists = self.hydrate_lists_basic(lists).await;
93
91
94
92
Some(build_threadgate_view(
···
102
100
threadgates: Vec<models::Threadgate>,
103
101
) -> HashMap<String, ThreadgateView> {
104
102
let lists = threadgates.iter().fold(Vec::new(), |mut acc, c| {
105
105
-
acc.extend(c.allowed_lists.iter().flatten().cloned());
103
103
+
if let Some(lists) = &c.allowed_lists {
104
104
+
acc.extend(lists.iter().flatten().cloned());
105
105
+
}
106
106
acc
107
107
});
108
108
let lists = self.hydrate_lists_basic(lists).await;
···
110
110
threadgates
111
111
.into_iter()
112
112
.map(|threadgate| {
113
113
-
let this_lists = threadgate
114
114
-
.allowed_lists
115
115
-
.iter()
116
116
-
.filter_map(|v| v.clone().and_then(|v| lists.get(&v).cloned()))
117
117
-
.collect();
113
113
+
let this_lists = match &threadgate.allowed_lists {
114
114
+
Some(allowed_lists) => allowed_lists
115
115
+
.iter()
116
116
+
.filter_map(|v| v.clone().and_then(|v| lists.get(&v).cloned()))
117
117
+
.collect(),
118
118
+
None => Vec::new(),
119
119
+
};
118
120
119
121
(
120
122
threadgate.at_uri.clone(),