mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-24 23:42:18 +00:00
refactor(urls): fold the cache-hit caption branch into one call
caption_from_fields already returns truncate_caption(built_in) for an empty format, which is exactly what the if-branch did; passing cached.caption as built_in makes both paths one call. The format path is unmoved -- built_in is read only when the format is empty.
This commit is contained in:
@@ -643,20 +643,18 @@ async fn url_media_inner(
|
||||
.get(site)
|
||||
.cloned()
|
||||
.unwrap_or_default();
|
||||
let caption = if format.is_empty() {
|
||||
x_media::site::truncate_caption(&cached.caption)
|
||||
} else {
|
||||
x_media::site::caption_from_fields(
|
||||
&format,
|
||||
"",
|
||||
&cached.url,
|
||||
&cached.author,
|
||||
&cached.author_url,
|
||||
&cached.title,
|
||||
&cached.content,
|
||||
&cached.tags,
|
||||
)
|
||||
};
|
||||
// One call for both: `caption_from_fields` returns the truncated
|
||||
// built-in caption itself when the chat has no format for this site.
|
||||
let caption = x_media::site::caption_from_fields(
|
||||
&format,
|
||||
&cached.caption,
|
||||
&cached.url,
|
||||
&cached.author,
|
||||
&cached.author_url,
|
||||
&cached.title,
|
||||
&cached.content,
|
||||
&cached.tags,
|
||||
);
|
||||
let items: Vec<MediaItemPayload> = cached
|
||||
.media
|
||||
.iter()
|
||||
|
||||
Reference in New Issue
Block a user