refactor(site): drop RenderData's url field, source_url already carries it

Every adapter built RenderData { url } from the exact value it then moved into Fetched.source_url — a copy of the same canonical URL held in two places, feeding one placeholder. caption_with reads {url} from self.source_url now and the field is gone from the struct (bsky's and twitter's halves of this change landed with their caption commits; their render builders no longer set it either).
This commit is contained in:
2026-09-24 04:37:54 +08:00
parent 2ec13a0624
commit c49e2175a1
4 changed files with 7 additions and 9 deletions
@@ -289,7 +289,6 @@ impl From<model::Item> for Fetched {
sensitive: false, sensitive: false,
site_id: "bilibili", site_id: "bilibili",
render_data: Some(RenderData { render_data: Some(RenderData {
url,
author: encode_text(&author).into_owned(), author: encode_text(&author).into_owned(),
author_url, author_url,
title: encode_text(&title).into_owned(), title: encode_text(&title).into_owned(),
@@ -133,7 +133,6 @@ impl From<model::Note> for Fetched {
sensitive, sensitive,
site_id: "misskey", site_id: "misskey",
render_data: Some(RenderData { render_data: Some(RenderData {
url,
author: encode_text(&author).into_owned(), author: encode_text(&author).into_owned(),
author_url: author_url.clone(), author_url: author_url.clone(),
title: String::new(), title: String::new(),
+7 -6
View File
@@ -69,13 +69,14 @@ pub struct Fetched {
/// ///
/// `author`, `title`, `content` and `tags` come from the site API (post /// `author`, `title`, `content` and `tags` come from the site API (post
/// text, display names, descriptions) and are HTML-escaped at construction. /// text, display names, descriptions) and are HTML-escaped at construction.
/// `url` and `author_url` stay raw: they are canonical URLs the adapter /// `author_url` stays raw: it is a canonical URL the adapter builds from
/// builds from numeric ids and API-constrained handles/DIDs, so they carry /// numeric ids and API-constrained handles/DIDs, so it carries no escapable
/// no escapable character — the bot's `/test` report relies on that when it /// character — the bot's `/test` report relies on that when it embeds it.
/// embeds them. /// `{url}` needs no copy here: [`Fetched::source_url`] is the same canonical
/// URL every adapter would have handed this struct, and `caption_with` reads
/// it from there.
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct RenderData { pub(crate) struct RenderData {
pub url: String,
pub author: String, pub author: String,
pub author_url: String, pub author_url: String,
pub title: String, pub title: String,
@@ -125,7 +126,7 @@ impl Fetched {
(Some(data), false) => caption_from_fields( (Some(data), false) => caption_from_fields(
format, format,
"", "",
&data.url, &self.source_url,
&data.author, &data.author,
&data.author_url, &data.author_url,
&data.title, &data.title,
@@ -289,7 +289,6 @@ impl From<Illustration> for Fetched {
.collect::<Vec<_>>() .collect::<Vec<_>>()
.join(" "); .join(" ");
let render_data = Some(crate::site::RenderData { let render_data = Some(crate::site::RenderData {
url: url.clone(),
author: encode_text(&illustration.author).into_owned(), author: encode_text(&illustration.author).into_owned(),
author_url: author_url.clone(), author_url: author_url.clone(),
title: encode_text(&illustration.title).into_owned(), title: encode_text(&illustration.title).into_owned(),