78d83d3e98
PROJ-21 Phase 4:
- internal/index/tenant_manager.go: TenantIndexManager mit lazy-loading Pool
- internal/index/tenant_worker.go: TenantIndexWorker leitet Submit an richtigen Index
- Jeder Mandant bekommt eigenes Xapian-Verzeichnis (tenant-<id>/)
- handleSearch nutzt direkt Tenant-Index statt nachgelagertem Post-Filter
- runBackfill re-indexiert pro Mandant beim Start
PROJ-23 / PROJ-16 Phase B:
- internal/ldapconfig/tenant_store.go: TenantStore mit AES-256-GCM für tenant_ldap
- internal/api/ldap_tenants.go: 8 neue Handler (GET/PUT/DELETE/test für
/api/tenant/ldap und /api/admin/tenants/{id}/ldap)
- internal/auth/auth.go: Login-Fallback prüft tenant_ldap nach globalem LDAP
(Domain-Extraktion → tenant_ldap config → UpsertLDAPUser mit tenant_id)
- internal/api/server.go: SetTenantLDAP(), neue Routen registriert
- internal/tenantstore/store.go: GetByDomain() Interface für auth-Package
- cmd/archivmail/main.go: TenantLDAPStore + TenantIndexManager verdrahtet
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
package index
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
// MailDocument is the indexed representation of a stored email.
|
|
type MailDocument struct {
|
|
ID string
|
|
From string
|
|
To string
|
|
Subject string
|
|
Body string
|
|
AttachNames string
|
|
HasAttachment bool
|
|
Date time.Time
|
|
Size int64
|
|
TenantID *int64 // nil = global / superadmin context
|
|
}
|
|
|
|
// SearchRequest specifies search parameters.
|
|
type SearchRequest struct {
|
|
Query string
|
|
From string
|
|
To string
|
|
OwnEmail string
|
|
DateFrom *time.Time
|
|
DateTo *time.Time
|
|
HasAttachment *bool // nil=no filter, true=only with, false=only without
|
|
Sort string // "relevance", "date_asc", "date_desc" (default: date_desc)
|
|
PageSize int
|
|
Page int
|
|
}
|
|
|
|
// Hit is a single search result.
|
|
type Hit struct {
|
|
ID string `json:"id"`
|
|
Score float64 `json:"score"`
|
|
}
|
|
|
|
// SearchResult holds paginated search results.
|
|
type SearchResult struct {
|
|
Total int
|
|
Hits []Hit
|
|
}
|
|
|
|
// Indexer is the interface for full-text email indexing.
|
|
type Indexer interface {
|
|
IndexSync(doc MailDocument) error
|
|
Search(req SearchRequest) (*SearchResult, error)
|
|
Delete(id string) error
|
|
Close() error
|
|
}
|
|
|
|
// New creates an Indexer for the specified backend.
|
|
func New(dir string, batchSize int, backend string) (Indexer, error) {
|
|
switch backend {
|
|
case "xapian":
|
|
return newXapian(dir)
|
|
default:
|
|
return nil, fmt.Errorf("unknown index backend: %q (supported: xapian)", backend)
|
|
}
|
|
}
|