redgifs: single-word queries that are creator names go to the creator
This commit is contained in:
@@ -560,6 +560,24 @@ impl Provider for RedgifsProvider {
|
||||
|
||||
let sort = Sort::from_sort_id(&sort);
|
||||
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 {
|
||||
Ok(items) => items,
|
||||
|
||||
Reference in New Issue
Block a user