fikfap: single-word queries that are profile names go to the creator
This commit is contained in:
@@ -639,6 +639,24 @@ impl Provider for FikfapProvider {
|
||||
.map(str::trim)
|
||||
.filter(|value| !value.is_empty());
|
||||
let target = Self::pick_target(normalized_query, &sort, &options);
|
||||
// A single-word query that is an existing profile name goes to that
|
||||
// creator's posts (checked against the profile endpoint); a profile
|
||||
// without posts falls back to the keyword search.
|
||||
if let Target::Search(query) = &target {
|
||||
if !query.contains(char::is_whitespace) {
|
||||
if let Ok(Some(profile)) = self.fetch_user_profile(query, &options).await {
|
||||
let user = Target::User(profile.username);
|
||||
if let Ok(items) = self
|
||||
.fetch_target_items(user, 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