Files

30 lines
692 B
Go

package webui
import (
"context"
"strings"
"github.com/samcharles93/archie-core/internal/domain/identity"
)
// actorNames resolves each actor once per response; stable IDs stay in the wire record.
func (s *Server) actorNames(ctx context.Context) func(string) string {
names := map[string]string{}
return func(id string) string {
if label, ok := names[id]; ok {
return label
}
label := id
if strings.Count(id, "-") == 4 {
label = "Unavailable identity"
}
if s.Identities != nil {
if actor, err := s.Identities.Get(ctx, identity.IdentityID(id)); err == nil && actor.DisplayName != "" {
label = actor.DisplayName
}
}
names[id] = label
return label
}
}