From 0ed0f0dc1f54fbe534cc1ed79ede7ec06586393a Mon Sep 17 00:00:00 2001 From: Denis Nutiu Date: Wed, 1 Jan 2025 17:05:43 +0200 Subject: [PATCH] add langs field for content language --- bot/src/bluesky/atproto.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bot/src/bluesky/atproto.rs b/bot/src/bluesky/atproto.rs index ca8e1ab..ff98668 100644 --- a/bot/src/bluesky/atproto.rs +++ b/bot/src/bluesky/atproto.rs @@ -79,6 +79,8 @@ pub struct ATprotoRepoCreateRecordRecord { pub text: String, #[serde(rename(serialize = "createdAt", deserialize = "createdAt"))] pub created_at: String, + #[serde(skip_serializing_if = "Vec::is_empty")] + pub langs: Vec, #[serde(skip_serializing_if = "Option::is_none")] pub embed: Option, } @@ -88,6 +90,7 @@ impl ATprotoRepoCreateRecordRecord { ATprotoRepoCreateRecordRecord { text: text.to_string(), created_at: date.to_rfc3339(), + langs: vec![String::from("ro-RO")], embed, } } @@ -173,7 +176,7 @@ mod tests { assert_eq!( json, - r#"{"repo":"nuculabs.dev","collection":"app.bsky.feed.post","record":{"text":"some post","createdAt":"2024-12-30T13:45:00+00:00"}}"# + r#"{"repo":"nuculabs.dev","collection":"app.bsky.feed.post","record":{"text":"some post","createdAt":"2024-12-30T13:45:00+00:00","langs":["ro-RO"]}}"# ); Ok(()) @@ -202,7 +205,7 @@ mod tests { assert_eq!( json, - r#"{"repo":"nuculabs.dev","collection":"app.bsky.feed.post","record":{"text":"some post","createdAt":"2024-12-30T13:45:00+00:00","embed":{"$type":"app.bsky.embed.external","external":{"uri":"https://some-news.ro/some","title":"Some very important news","description":"The description of the news"}}}}"# + r#"{"repo":"nuculabs.dev","collection":"app.bsky.feed.post","record":{"text":"some post","createdAt":"2024-12-30T13:45:00+00:00","langs":["ro-RO"],"embed":{"$type":"app.bsky.embed.external","external":{"uri":"https://some-news.ro/some","title":"Some very important news","description":"The description of the news"}}}}"# ); Ok(()) @@ -236,7 +239,7 @@ mod tests { assert_eq!( json, - r#"{"repo":"nuculabs.dev","collection":"app.bsky.feed.post","record":{"text":"some post","createdAt":"2024-12-30T13:45:00+00:00","embed":{"$type":"app.bsky.embed.external","external":{"uri":"https://some-news.ro/some","title":"Some very important news","description":"The description of the news","thumb":{"$type":"blob","ref":{"$link":"bafkreiass5vjx467rdtm77ey4kkuz667wldaffq7z3nmvqxm2bwk3hiemm"},"mimeType":"image/jpeg","size":122}}}}}"# + r#"{"repo":"nuculabs.dev","collection":"app.bsky.feed.post","record":{"text":"some post","createdAt":"2024-12-30T13:45:00+00:00","langs":["ro-RO"],"embed":{"$type":"app.bsky.embed.external","external":{"uri":"https://some-news.ro/some","title":"Some very important news","description":"The description of the news","thumb":{"$type":"blob","ref":{"$link":"bafkreiass5vjx467rdtm77ey4kkuz667wldaffq7z3nmvqxm2bwk3hiemm"},"mimeType":"image/jpeg","size":122}}}}}"# ); Ok(())