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
feat: pinned posts
mia.omg.lol
5 months ago
caa8a8f2
3c1bd936
verified
This commit was signed with the committer's
known signature
.
mia.omg.lol
SSH Key Fingerprint:
SHA256:eb+NhC0QEl+XKRuFP/97oH6LEz0TXTKPXGDIAI5y7CQ=
+37
-1
2 changed files
expand all
collapse all
unified
split
parakeet
src
db.rs
xrpc
app_bsky
feed
posts.rs
+16
parakeet/src/db.rs
···
180
180
.load(conn)
181
181
.await
182
182
}
183
183
+
184
184
+
pub async fn get_pinned_post_uri(
185
185
+
conn: &mut AsyncPgConnection,
186
186
+
did: &str,
187
187
+
) -> QueryResult<Option<String>> {
188
188
+
schema::profiles::table
189
189
+
.select(schema::profiles::pinned_uri.assume_not_null())
190
190
+
.filter(
191
191
+
schema::profiles::did
192
192
+
.eq(did)
193
193
+
.and(schema::profiles::pinned_uri.is_not_null()),
194
194
+
)
195
195
+
.get_result(conn)
196
196
+
.await
197
197
+
.optional()
198
198
+
}
+21
-1
parakeet/src/xrpc/app_bsky/feed/posts.rs
···
207
207
208
208
let hyd = StatefulHydrator::new(&state.dataloaders, &state.cdn, &labelers, maybe_auth);
209
209
210
210
+
let pin = match query.include_pins && query.cursor.is_none() {
211
211
+
false => None,
212
212
+
true => match crate::db::get_pinned_post_uri(&mut conn, &did).await? {
213
213
+
Some(post) => hyd.hydrate_post(post).await,
214
214
+
None => None,
215
215
+
},
216
216
+
};
217
217
+
210
218
let limit = query.limit.unwrap_or(50).clamp(1, 100);
211
219
212
220
let mut posts_query = schema::posts::table
···
259
267
260
268
let mut posts = hyd.hydrate_feed_posts(at_uris).await;
261
269
262
262
-
let feed = results
270
270
+
let mut feed: Vec<_> = results
263
271
.into_iter()
264
272
.filter_map(|(_, uri)| posts.remove(&uri))
265
273
.collect();
274
274
+
275
275
+
if let Some(post) = pin {
276
276
+
feed.insert(
277
277
+
0,
278
278
+
FeedViewPost {
279
279
+
post,
280
280
+
reply: None,
281
281
+
reason: Some(FeedViewPostReason::Pin),
282
282
+
feed_context: None,
283
283
+
},
284
284
+
);
285
285
+
}
266
286
267
287
Ok(Json(FeedRes { cursor, feed }))
268
288
}