feat(catalog): mbox header scan, company legal-suffix match, apply order

Add --mbox-headers for Thunderbird folder files; strip GmbH/& Co. KG in
CompanyGroupingKey; FindCompany falls back to full scan; apply companies
before persons. Tightens role-mailbox noise filters.
This commit is contained in:
2026-07-26 11:34:42 +01:00
parent 8b764a36a1
commit e07cf743f9
3 changed files with 40 additions and 3 deletions
+17 -1
View File
@@ -46,9 +46,12 @@ func (c *Client) GetContact(ctx context.Context, contactID string) (map[string]a
}
// FindCompany searches for a company contact with an exact (case-insensitive)
// displayName match. Returns nil when not found.
// displayName match after slogan/legal-suffix normalization. Returns nil when not found.
func (c *Client) FindCompany(ctx context.Context, name string) (map[string]any, error) {
needle := CompanyGroupingKey(name)
if needle == "" {
return nil, nil
}
const page = 50
for start := 0; ; start += page {
items, total, err := c.ListContacts(ctx, page, start, name)
@@ -67,6 +70,19 @@ func (c *Client) FindCompany(ctx context.Context, name string) (map[string]any,
break
}
}
// Search filter may miss longer legal names; fall back to a full company scan.
all, err := c.ListAllContacts(ctx)
if err != nil {
return nil, err
}
for _, co := range all {
if !isCompany(co) {
continue
}
if CompanyGroupingKey(fmt.Sprint(co["displayName"])) == needle {
return co, nil
}
}
return nil, nil
}