Fix username autocomplete for Pleroma instances and remote users

- Enhanced API search limits from 10 to 40 users with remote resolution
- Added 'resolve: True' parameter to enable finding users from remote instances
- Improved filtering logic to match username parts before @ symbol
- Increased follower/following search limits from 50 to 100 each
- Added Pleroma compatibility with parameter validation and fallback endpoints
- Fixed state management for autocomplete re-triggering after API calls
- Now successfully finds remote users like storm@social.wolfe.casa

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-07-20 20:43:32 -04:00
parent 037fcbf7e0
commit daca679fb9
3 changed files with 46 additions and 10 deletions

View File

@@ -198,14 +198,32 @@ class ActivityPubClient:
def search_accounts(self, query: str, limit: int = 10) -> List[Dict]:
"""Search for accounts by username"""
# Ensure limit is a valid integer for Pleroma compatibility
limit = max(1, min(int(limit), 80))
params = {
'q': query,
'type': 'accounts',
'limit': limit
'limit': limit,
'resolve': True # Enable remote user resolution
}
result = self._make_request('GET', '/api/v2/search', params=params)
return result.get('accounts', [])
try:
# Try v2 search first (preferred)
result = self._make_request('GET', '/api/v2/search', params=params)
return result.get('accounts', [])
except Exception:
try:
# Fallback to v1 accounts search (Pleroma-friendly)
fallback_params = {
'q': query,
'limit': limit,
'resolve': True
}
return self._make_request('GET', '/api/v1/accounts/search', params=fallback_params)
except Exception:
# Return empty list if both fail
return []
def search(self, query: str, account_id: Optional[str] = None,
max_id: Optional[str] = None, min_id: Optional[str] = None,