mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-25 23:52:04 +00:00
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:
@@ -289,7 +289,6 @@ impl From<model::Item> for Fetched {
|
||||
sensitive: false,
|
||||
site_id: "bilibili",
|
||||
render_data: Some(RenderData {
|
||||
url,
|
||||
author: encode_text(&author).into_owned(),
|
||||
author_url,
|
||||
title: encode_text(&title).into_owned(),
|
||||
|
||||
@@ -133,7 +133,6 @@ impl From<model::Note> for Fetched {
|
||||
sensitive,
|
||||
site_id: "misskey",
|
||||
render_data: Some(RenderData {
|
||||
url,
|
||||
author: encode_text(&author).into_owned(),
|
||||
author_url: author_url.clone(),
|
||||
title: String::new(),
|
||||
|
||||
@@ -69,13 +69,14 @@ pub struct Fetched {
|
||||
///
|
||||
/// `author`, `title`, `content` and `tags` come from the site API (post
|
||||
/// text, display names, descriptions) and are HTML-escaped at construction.
|
||||
/// `url` and `author_url` stay raw: they are canonical URLs the adapter
|
||||
/// builds from numeric ids and API-constrained handles/DIDs, so they carry
|
||||
/// no escapable character — the bot's `/test` report relies on that when it
|
||||
/// embeds them.
|
||||
/// `author_url` stays raw: it is a canonical URL the adapter builds from
|
||||
/// numeric ids and API-constrained handles/DIDs, so it carries no escapable
|
||||
/// character — the bot's `/test` report relies on that when it embeds it.
|
||||
/// `{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)]
|
||||
pub(crate) struct RenderData {
|
||||
pub url: String,
|
||||
pub author: String,
|
||||
pub author_url: String,
|
||||
pub title: String,
|
||||
@@ -125,7 +126,7 @@ impl Fetched {
|
||||
(Some(data), false) => caption_from_fields(
|
||||
format,
|
||||
"",
|
||||
&data.url,
|
||||
&self.source_url,
|
||||
&data.author,
|
||||
&data.author_url,
|
||||
&data.title,
|
||||
|
||||
@@ -289,7 +289,6 @@ impl From<Illustration> for Fetched {
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ");
|
||||
let render_data = Some(crate::site::RenderData {
|
||||
url: url.clone(),
|
||||
author: encode_text(&illustration.author).into_owned(),
|
||||
author_url: author_url.clone(),
|
||||
title: encode_text(&illustration.title).into_owned(),
|
||||
|
||||
Reference in New Issue
Block a user