mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-10-06 01:22:16 +00:00
refactor(site): drop site_id_from_key, split the key at its caller
site_id_from_key split the prefix out and then walked the registry to confirm the prefix was a registered site id — a round trip over a value cache_key itself produced from that registry: the unknown and no-colon branches were unreachable for any key the bot makes. The single caller (the link-cache hit path) splits the prefix directly; the registry-echo test and the misskey assertion of it go with it.
This commit is contained in:
@@ -554,8 +554,10 @@ async fn url_media_inner(
|
||||
log::debug!("link cache hit for {key}");
|
||||
let chat_data = ctx.chat_store.get(chat_id).await;
|
||||
// Cache keys are prefixed with the site id ("twitter:…"), matching
|
||||
// the value a fresh fetch would read from Fetched::site_id.
|
||||
let site = x_media::site::site_id_from_key(&key);
|
||||
// the value a fresh fetch would read from Fetched::site_id. The key
|
||||
// came out of cache_key, so its prefix is a registered id by
|
||||
// construction — splitting it off is the whole lookup.
|
||||
let site = key.split(':').next().unwrap_or("");
|
||||
let format = chat_data.format_for(site);
|
||||
// One call for both: `caption_from_fields` returns the truncated
|
||||
// built-in caption itself when the chat has no format for this site.
|
||||
|
||||
Reference in New Issue
Block a user