diff --git a/consumer/src/db/copy.rs b/consumer/src/db/copy.rs index 17db6f0f..68065703 100644 --- a/consumer/src/db/copy.rs +++ b/consumer/src/db/copy.rs @@ -5,9 +5,9 @@ use chrono::prelude::*; use deadpool_postgres::Transaction; use futures::pin_mut; use ipld_core::cid::Cid; +use lexica::StrongRef; use tokio_postgres::binary_copy::BinaryCopyInWriter; use tokio_postgres::types::Type; -use lexica::StrongRef; // StrongRefs are used in both likes and reposts const STRONGREF_TYPES: &[Type] = &[ @@ -19,12 +19,7 @@ const STRONGREF_TYPES: &[Type] = &[ Type::TEXT, Type::TIMESTAMP, ]; -type StrongRefRow = ( - String, - StrongRef, - Option, - DateTime, -); +type StrongRefRow = (String, StrongRef, Option, DateTime); // SubjectRefs are used in both blocks and follows const SUBJECT_TYPES: &[Type] = &[Type::TEXT, Type::TEXT, Type::TEXT, Type::TIMESTAMP]; diff --git a/consumer/src/db/record.rs b/consumer/src/db/record.rs index bca14047..3293170a 100644 --- a/consumer/src/db/record.rs +++ b/consumer/src/db/record.rs @@ -37,7 +37,14 @@ pub async fn bookmark_upsert( conn.execute( include_str!("sql/bookmarks_upsert.sql"), - &[&repo, &rkey, &rec.subject, &rec_type, &rec.tags, &rec.created_at], + &[ + &repo, + &rkey, + &rec.subject, + &rec_type, + &rec.tags, + &rec.created_at, + ], ) .await } diff --git a/consumer/src/firehose/mod.rs b/consumer/src/firehose/mod.rs index 1bb98c95..01395680 100644 --- a/consumer/src/firehose/mod.rs +++ b/consumer/src/firehose/mod.rs @@ -119,8 +119,7 @@ impl FirehoseConsumer { } "#sync" => { counter!("firehose_events.total", "event" => "sync").increment(1); - let event: AtpSyncEvent = - serde_ipld_dagcbor::from_reader(&mut reader)?; + let event: AtpSyncEvent = serde_ipld_dagcbor::from_reader(&mut reader)?; // increment the seq if self.seq < event.seq { diff --git a/consumer/src/indexer/mod.rs b/consumer/src/indexer/mod.rs index a1cab307..b0ee18b2 100644 --- a/consumer/src/indexer/mod.rs +++ b/consumer/src/indexer/mod.rs @@ -213,7 +213,8 @@ async fn process_sync( rc: &mut MultiplexedConnection, sync: AtpSyncEvent, ) -> eyre::Result<()> { - let Some((sync_state, Some(current_rev))) = db::actor_get_repo_status(conn, &sync.did).await? else { + let Some((sync_state, Some(current_rev))) = db::actor_get_repo_status(conn, &sync.did).await? + else { return Ok(()); }; @@ -866,9 +867,7 @@ pub async fn index_op_delete( redis::AsyncTypedCommands::del(rc, format!("profile#{repo}")).await?; db::chat_decl_delete(conn, repo).await? } - CollectionType::CommunityLexiconBookmark => { - db::bookmark_delete(conn, rkey, repo).await? - } + CollectionType::CommunityLexiconBookmark => db::bookmark_delete(conn, rkey, repo).await?, _ => unreachable!(), }; diff --git a/consumer/src/indexer/types.rs b/consumer/src/indexer/types.rs index 795b9e5d..de9181f1 100644 --- a/consumer/src/indexer/types.rs +++ b/consumer/src/indexer/types.rs @@ -42,7 +42,7 @@ pub enum RecordTypes { #[serde(rename = "chat.bsky.actor.declaration")] ChatBskyActorDeclaration(records::ChatBskyActorDeclaration), #[serde(rename = "community.lexicon.bookmarks.bookmark")] - CommunityLexiconBookmark(lexica::community_lexicon::bookmarks::Bookmark) + CommunityLexiconBookmark(lexica::community_lexicon::bookmarks::Bookmark), } #[derive(Debug, PartialOrd, PartialEq, Deserialize, Serialize)] diff --git a/consumer/src/utils.rs b/consumer/src/utils.rs index 4be0db8d..1e10a294 100644 --- a/consumer/src/utils.rs +++ b/consumer/src/utils.rs @@ -1,5 +1,5 @@ -use serde::{Deserialize, Deserializer}; use lexica::{Blob, StrongRef}; +use serde::{Deserialize, Deserializer}; // see https://deer.social/profile/did:plc:63y3oh7iakdueqhlj6trojbq/post/3ltuv4skhqs2h pub fn safe_string<'de, D: Deserializer<'de>>(deserializer: D) -> Result { @@ -12,9 +12,7 @@ pub fn blob_ref(blob: Option) -> Option { blob.map(|blob| blob.cid.to_string()) } -pub fn strongref_to_parts( - strongref: Option<&StrongRef>, -) -> (Option, Option) { +pub fn strongref_to_parts(strongref: Option<&StrongRef>) -> (Option, Option) { strongref .map(|sr| (sr.uri.clone(), sr.cid.to_string())) .unzip() diff --git a/lexica/src/app_bsky/feed.rs b/lexica/src/app_bsky/feed.rs index 45fd4c7f..3a71771c 100644 --- a/lexica/src/app_bsky/feed.rs +++ b/lexica/src/app_bsky/feed.rs @@ -219,7 +219,5 @@ pub enum SkeletonReason { #[serde(rename = "app.bsky.feed.defs#skeletonReasonPin")] Pin {}, #[serde(rename = "app.bsky.feed.defs#skeletonReasonRepost")] - Repost { - repost: String, - }, + Repost { repost: String }, } diff --git a/lexica/src/community_lexicon/bookmarks.rs b/lexica/src/community_lexicon/bookmarks.rs index f5cda6ea..d6d23eaa 100644 --- a/lexica/src/community_lexicon/bookmarks.rs +++ b/lexica/src/community_lexicon/bookmarks.rs @@ -11,4 +11,4 @@ pub struct Bookmark { #[serde(skip_serializing_if = "Vec::is_empty")] pub tags: Vec, pub created_at: DateTime, -} \ No newline at end of file +} diff --git a/lexica/src/community_lexicon/mod.rs b/lexica/src/community_lexicon/mod.rs index 3f736c29..bf3e8889 100644 --- a/lexica/src/community_lexicon/mod.rs +++ b/lexica/src/community_lexicon/mod.rs @@ -1 +1 @@ -pub mod bookmarks; \ No newline at end of file +pub mod bookmarks; diff --git a/lexica/src/utils.rs b/lexica/src/utils.rs index a78932b8..5d1e5fbd 100644 --- a/lexica/src/utils.rs +++ b/lexica/src/utils.rs @@ -27,5 +27,5 @@ where LinkRef { link: inp.to_string(), } - .serialize(serializer) -} \ No newline at end of file + .serialize(serializer) +} diff --git a/parakeet-db/src/models.rs b/parakeet-db/src/models.rs index 71a3a10d..c7cee709 100644 --- a/parakeet-db/src/models.rs +++ b/parakeet-db/src/models.rs @@ -292,7 +292,9 @@ pub struct LabelerService { pub indexed_at: NaiveDateTime, } -#[derive(Clone, Debug, Serialize, Deserialize, Queryable, Selectable, Identifiable, Associations)] +#[derive( + Clone, Debug, Serialize, Deserialize, Queryable, Selectable, Identifiable, Associations, +)] #[diesel(table_name = crate::schema::labeler_defs)] #[diesel(belongs_to(LabelerService, foreign_key = labeler))] #[diesel(check_for_backend(diesel::pg::Pg))] @@ -408,4 +410,4 @@ pub struct NewBookmark<'a> { pub subject_cid: Option, pub subject_type: &'a str, pub tags: Vec, -} \ No newline at end of file +} diff --git a/parakeet-db/src/types.rs b/parakeet-db/src/types.rs index 43bc2ea0..a9300cde 100644 --- a/parakeet-db/src/types.rs +++ b/parakeet-db/src/types.rs @@ -85,7 +85,7 @@ macro_rules! text_enum { use std::io::Write; let val = self.to_string(); - out.write(val.as_bytes())?; + out.write_all(val.as_bytes())?; Ok(diesel::serialize::IsNull::No) } } diff --git a/parakeet/src/xrpc/app_bsky/bookmark.rs b/parakeet/src/xrpc/app_bsky/bookmark.rs index 229393b9..5c117a34 100644 --- a/parakeet/src/xrpc/app_bsky/bookmark.rs +++ b/parakeet/src/xrpc/app_bsky/bookmark.rs @@ -8,9 +8,9 @@ use axum::Json; use diesel::prelude::*; use diesel_async::RunQueryDsl; use lexica::app_bsky::bookmark::{BookmarkView, BookmarkViewItem}; +use lexica::StrongRef; use parakeet_db::{models, schema}; use serde::{Deserialize, Serialize}; -use lexica::StrongRef; const BSKY_ALLOWED_TYPES: &[&str] = &["app.bsky.feed.post"]; @@ -125,12 +125,13 @@ pub async fn get_bookmarks( // otherwise just ditch. we should have one. let cid = bookmark.subject_cid.or(maybe_cid)?; - let item = maybe_item.map(BookmarkViewItem::Post).unwrap_or( - BookmarkViewItem::NotFound { - uri: bookmark.subject.clone(), - not_found: true, - }, - ); + let item = + maybe_item + .map(BookmarkViewItem::Post) + .unwrap_or(BookmarkViewItem::NotFound { + uri: bookmark.subject.clone(), + not_found: true, + }); let subject = StrongRef::new_from_str(bookmark.subject, &cid).ok()?; diff --git a/parakeet/src/xrpc/app_bsky/graph/relations.rs b/parakeet/src/xrpc/app_bsky/graph/relations.rs index 804686a3..2bd9af95 100644 --- a/parakeet/src/xrpc/app_bsky/graph/relations.rs +++ b/parakeet/src/xrpc/app_bsky/graph/relations.rs @@ -50,7 +50,7 @@ pub async fn get_blocks( .map(|(last, _)| last.timestamp_millis().to_string()); let dids = results.iter().map(|(_, did)| did.clone()).collect(); - + let profiles = hyd.hydrate_profiles(dids).await; let blocks = profiles.into_values().collect::>(); diff --git a/parakeet/src/xrpc/app_bsky/mod.rs b/parakeet/src/xrpc/app_bsky/mod.rs index 1fde8c8a..ca6a74d7 100644 --- a/parakeet/src/xrpc/app_bsky/mod.rs +++ b/parakeet/src/xrpc/app_bsky/mod.rs @@ -68,4 +68,4 @@ pub fn routes() -> Router { async fn not_implemented() -> axum::http::StatusCode { axum::http::StatusCode::NOT_IMPLEMENTED -} \ No newline at end of file +}