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

This commit is contained in:
Simon
2026-10-17 06:01:34 +00:00
parent 813e2ec2ca
commit 270b327f73

View File

@@ -639,6 +639,24 @@ impl Provider for FikfapProvider {
.map(str::trim) .map(str::trim)
.filter(|value| !value.is_empty()); .filter(|value| !value.is_empty());
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 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 { match self.fetch_target_items(target, page, per_page, &options).await {
Ok(items) => items, Ok(items) => items,