Use display name instead of username for shared calendar owners

Add db.DisplayName(username), returning the user's display name if
set, otherwise the raw username. Use it everywhere a shared calendar's
owner is shown: the web calendar legend ("shared by ..."), the "new
event"/edit calendar select label, the dashboard's "Shared with you"
list, and the CalDAV-side description/name-collision disambiguation
("Name (Owner)") shown to CalDAV clients like DAVx5.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-08-21 06:41:51 +02:00
co-authored by Copilot
parent 8b10386c91
commit d0e1dab837
4 changed files with 22 additions and 8 deletions
+3 -3
View File
@@ -444,7 +444,7 @@ func (s *Server) collectCalendarEvents(username string, gridStart, gridEnd time.
hasWritable = true
}
calSummaries = append(calSummaries, templates.CalendarSummary{
Ref: entry.Ref, Name: entry.Name, Owner: entry.Owner, Color: entry.Color,
Ref: entry.Ref, Name: entry.Name, Owner: s.dbase.DisplayName(entry.Owner), Color: entry.Color,
Shared: entry.Owner != username, Writable: entry.Writable, Virtual: entry.Virtual,
})
@@ -565,7 +565,7 @@ func (s *Server) handleEventNew(w http.ResponseWriter, r *http.Request) {
}
label := e.Name
if e.Owner != username {
label = e.Name + " (" + e.Owner + ")"
label = e.Name + " (" + s.dbase.DisplayName(e.Owner) + ")"
}
options = append(options, templates.CalendarOption{Ref: e.Ref, Label: label})
}
@@ -668,7 +668,7 @@ func (s *Server) handleEventEdit(w http.ResponseWriter, r *http.Request) {
form.CalRef = ref
label := name
if owner != username {
label = name + " (" + owner + ")"
label = name + " (" + s.dbase.DisplayName(owner) + ")"
}
form.CalendarLabel = label
form.Writable = owner == username
+2 -2
View File
@@ -26,7 +26,7 @@ func (s *Server) handleDashboard(w http.ResponseWriter, r *http.Request) {
}
for _, sh := range calShares {
sharedWithMe = append(sharedWithMe, templates.SharedWithMeItem{
Kind: "calendar", Owner: sh.Owner, Name: sh.CalendarName, Permission: string(sh.Permission),
Kind: "calendar", Owner: s.dbase.DisplayName(sh.Owner), Name: sh.CalendarName, Permission: string(sh.Permission),
})
}
bookShares, err := s.dbase.AddressBooksSharedWith(username)
@@ -35,7 +35,7 @@ func (s *Server) handleDashboard(w http.ResponseWriter, r *http.Request) {
}
for _, sh := range bookShares {
sharedWithMe = append(sharedWithMe, templates.SharedWithMeItem{
Kind: "addressbook", Owner: sh.Owner, Name: sh.AddressBookName, Permission: string(sh.Permission),
Kind: "addressbook", Owner: s.dbase.DisplayName(sh.Owner), Name: sh.AddressBookName, Permission: string(sh.Permission),
})
}