diff --git a/Cargo.lock b/Cargo.lock index f0c854ec..84864de7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2656,6 +2656,7 @@ dependencies = [ "async-recursion", "axum", "axum-extra", + "base64 0.22.1", "chrono", "dataloader", "deadpool", diff --git a/lexica/src/com_atproto/label.rs b/lexica/src/com_atproto/label.rs index 9f5fbf3b..ef97033e 100644 --- a/lexica/src/com_atproto/label.rs +++ b/lexica/src/com_atproto/label.rs @@ -145,5 +145,5 @@ pub struct Label { #[serde(skip_serializing_if = "Option::is_none")] pub exp: Option, #[serde(skip_serializing_if = "Option::is_none")] - pub sig: Option>, + pub sig: Option, } diff --git a/lexica/src/lib.rs b/lexica/src/lib.rs index 16f69b66..5242c85a 100644 --- a/lexica/src/lib.rs +++ b/lexica/src/lib.rs @@ -1,2 +1,10 @@ +use serde::Serialize; + pub mod app_bsky; pub mod com_atproto; + +#[derive(Clone, Debug, Serialize)] +pub struct JsonBytes { + #[serde(rename = "$bytes")] + pub bytes: String, +} diff --git a/parakeet/Cargo.toml b/parakeet/Cargo.toml index f61ae6ea..035fcc9f 100644 --- a/parakeet/Cargo.toml +++ b/parakeet/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" async-recursion = "1.1.1" axum = { version = "0.8", features = ["json"] } axum-extra = { version = "0.10.0", features = ["query", "typed-header"] } +base64 = "0.22" chrono = { version = "0.4.39", features = ["serde"] } dataloader = { path = "../dataloader-rs", default-features = false, features = ["runtime-tokio"] } deadpool = { version = "0.12.1", features = ["managed"] } diff --git a/parakeet/src/hydration/mod.rs b/parakeet/src/hydration/mod.rs index e2f8f641..d37afd86 100644 --- a/parakeet/src/hydration/mod.rs +++ b/parakeet/src/hydration/mod.rs @@ -3,6 +3,7 @@ use crate::loaders::Dataloaders; use crate::xrpc::cdn::BskyCdn; use crate::xrpc::extract::LabelConfigItem; +use base64::{prelude::BASE64_STANDARD, Engine}; use std::collections::HashMap; use std::sync::Arc; @@ -17,6 +18,10 @@ pub mod starter_packs; pub use profile::*; fn db_to_atp_label(input: parakeet_db::models::Label) -> lexica::com_atproto::label::Label { + let sig = input.sig.map(|sig| lexica::JsonBytes { + bytes: BASE64_STANDARD.encode(&sig), + }); + lexica::com_atproto::label::Label { ver: 1, src: input.labeler, @@ -25,7 +30,7 @@ fn db_to_atp_label(input: parakeet_db::models::Label) -> lexica::com_atproto::la val: input.label, cts: input.created_at, exp: input.expires, - sig: input.sig, + sig, } }