redgifs: single-word queries that are creator names go to the creator

This commit is contained in:
Simon
2026-10-17 06:05:54 +00:00
parent a486bc5502
commit 4c29d27b3e

View File

@@ -560,6 +560,24 @@ impl Provider for RedgifsProvider {
let sort = Sort::from_sort_id(&sort); let sort = Sort::from_sort_id(&sort);
let target = Self::pick_target(normalized_query, sort, &options); let target = Self::pick_target(normalized_query, sort, &options);
// A single-word query that is an existing creator name goes to that
// creator's gifs (checked against the users endpoint); a creator
// without gifs falls back to the keyword search.
if let Target::Query(text, _) = &target {
if !text.contains(char::is_whitespace) {
if let Ok(Some(profile)) = self.fetch_user_profile(text, &options).await {
let creator = Target::Creator(profile.username);
if let Ok(items) = self
.fetch_target_items(creator, page, per_page, &options)
.await
{
if !items.is_empty() {
return items;
}
}
}
}
}
match self.fetch_target_items(target, page, per_page, &options).await { match self.fetch_target_items(target, page, per_page, &options).await {
Ok(items) => items, Ok(items) => items,