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

feat(consumer): don't index pinned posts where the post isn't by the pinning did

mia.omg.lol e8510d71 e6b707d7

verified
+19 -7
+13 -7
consumer/src/indexer/mod.rs
··· 7 7 use crate::indexer::types::{ 8 8 AggregateDeltaStore, BackfillItem, BackfillItemInner, CollectionType, RecordTypes, 9 9 }; 10 + use crate::utils::at_uri_is_by; 10 11 use deadpool_postgres::{Object, Pool, Transaction}; 11 12 use did_resolver::Resolver; 12 13 use foldhash::quality::RandomState; ··· 551 552 rkey: &str, 552 553 ) -> eyre::Result<()> { 553 554 match record { 554 - RecordTypes::AppBskyActorProfile(record) => { 555 + RecordTypes::AppBskyActorProfile(mut record) => { 555 556 if rkey == "self" { 556 557 let labels = record.labels.clone(); 558 + 559 + // don't allow pinned posts that aren't by us. 560 + if let Some(pinned) = &record.pinned_post { 561 + if !at_uri_is_by(&pinned.uri, repo) { 562 + record.pinned_post = None; 563 + } 564 + } 565 + 557 566 db::profile_upsert(conn, repo, cid, record).await?; 558 567 559 568 if let Some(labels) = labels { ··· 629 638 } 630 639 } 631 640 RecordTypes::AppBskyFeedPostgate(record) => { 632 - let split_aturi = record.post.rsplitn(4, '/').collect::<Vec<_>>(); 633 - if repo != split_aturi[2] { 641 + if !at_uri_is_by(&record.post, repo) { 634 642 tracing::warn!("tried to create a postgate on a post we don't control!"); 635 643 return Ok(()); 636 644 } ··· 660 668 db::repost_insert(conn, rkey, repo, record).await?; 661 669 } 662 670 RecordTypes::AppBskyFeedThreadgate(record) => { 663 - let split_aturi = record.post.rsplitn(4, '/').collect::<Vec<_>>(); 664 - if repo != split_aturi[2] { 671 + if !at_uri_is_by(&record.post, repo) { 665 672 tracing::warn!("tried to create a threadgate on a post we don't control!"); 666 673 return Ok(()); 667 674 } ··· 701 708 db::list_block_insert(conn, at_uri, repo, record).await?; 702 709 } 703 710 RecordTypes::AppBskyGraphListItem(record) => { 704 - let split_aturi = record.list.rsplitn(4, '/').collect::<Vec<_>>(); 705 - if repo != split_aturi[2] { 711 + if !at_uri_is_by(&record.list, repo) { 706 712 // it's also probably a bad idea to log *all* the attempts to do this... 707 713 tracing::warn!("tried to create a listitem on a list we don't control!"); 708 714 return Ok(());
+6
consumer/src/utils.rs
··· 35 35 None 36 36 } 37 37 } 38 + 39 + pub fn at_uri_is_by(uri: &str, did: &str) -> bool { 40 + let split_aturi = uri.rsplitn(4, '/').collect::<Vec<_>>(); 41 + 42 + did == split_aturi[2] 43 + }