Files
Lucas RayanandClaude Sonnet 5.5 60c6f5731c fix(bimi): each domain's logo under its own URL, and the publisher actually wired
Two bugs found by the setup check right after the last deploy:

- every domain's BIMI record named the deployment's own mail host, and the
  server picked the domain from the host name, so only the primary domain's
  logo could be fetched: ciberlab.seg.br's record pointed at a 404. The logo
  and the certificate are now served at /.well-known/bimi/<domain>/..., the
  record names that, and the webmail routes it. The old path still answers
- SetBimiPublisher ran before SetBimiAPI, found no BIMI API to attach to and
  was dropped, so saving a logo never published the DNS record by itself. It is
  kept on the router now, so the order does not matter

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 18:49:52 -03:00

37 lines
1.2 KiB
Go

package main
import (
"context"
"log"
"time"
"lambdamail/protocols/internal/domain/bimi"
"lambdamail/protocols/internal/infrastructure/postgres"
httppresentation "lambdamail/protocols/internal/presentation/http"
)
// bimiPublication is what a domain's BIMI record should say, for the sync, the
// background sweep and the console alike. Read each time, so a logo saved a
// moment ago is what gets published and a removed one stops being published.
func bimiPublication(ctx context.Context, repo *postgres.BimiRepository, cfg config, domain string) bimi.Publication {
if repo == nil {
return bimi.Publication{}
}
logo, err := repo.Load(ctx, domain)
if err != nil {
// Unknown is not "no logo": returning an empty publication here would
// have the sync delete the record over a database hiccup.
log.Printf("BIMI: could not read the logo for %s, leaving its record alone: %v", domain, err)
return bimi.Publication{LogoURL: httppresentation.BimiLogoURL(cfg.PrimaryMailHost, domain)}
}
if logo == nil {
return bimi.Publication{}
}
return bimi.Publish(
logo.SVG, logo.VmcPEM, logo.VmcURL, domain,
httppresentation.BimiLogoURL(cfg.PrimaryMailHost, domain),
httppresentation.BimiVmcURL(cfg.PrimaryMailHost, domain),
time.Now(),
)
}