ultisuite-backend/internal/websearch/settings.go
R3D347HR4Y 556d5f416d Enhance API and configuration for contact discovery and public sharing
- Introduced new endpoints for contact discovery, including scanning, listing, and managing discovered contacts.
- Implemented retry logic for handling missing DAV credentials during contact operations.
- Added public share functionality for drive API, allowing users to manage public shares, including upload, delete, and rename operations.
- Updated Nextcloud configuration to support public share links and improved error handling for public share permissions.
- Enhanced logging and validation across contact and drive APIs for better error tracking and user feedback.
- Added tests for new contact matching and ranking functionalities to ensure accuracy and reliability.
2026-06-06 20:27:02 +02:00

44 lines
987 B
Go

package websearch
import (
"fmt"
"strings"
)
type ProviderType string
const ProviderBrave ProviderType = "brave"
type Provider struct {
ID string `json:"id"`
Name string `json:"name"`
Type ProviderType `json:"type"`
APIKey string `json:"api_key,omitempty"`
}
type Settings struct {
DefaultProviderID string `json:"default_provider_id"`
Providers []Provider `json:"providers"`
}
func ResolveProvider(settings Settings) (Provider, error) {
providerID := strings.TrimSpace(settings.DefaultProviderID)
if providerID != "" {
for _, p := range settings.Providers {
if p.ID == providerID && providerConfigured(p) {
return p, nil
}
}
}
for _, p := range settings.Providers {
if providerConfigured(p) {
return p, nil
}
}
return Provider{}, fmt.Errorf("no search provider configured")
}
func providerConfigured(p Provider) bool {
return strings.TrimSpace(p.APIKey) != "" && strings.TrimSpace(string(p.Type)) != ""
}