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:
@@ -382,7 +382,7 @@ func (b *Backend) calendarMeta(owner, realName, localName string) caldav.Calenda
|
||||
// their own calendars (see sharedDisplayName) — the Description still
|
||||
// always names the real calendar, only the client-visible Name changes.
|
||||
func (b *Backend) calendarMetaNamed(owner, realName, localName, displayName string) caldav.Calendar {
|
||||
desc := fmt.Sprintf("%s's %s calendar", owner, realName)
|
||||
desc := fmt.Sprintf("%s's %s calendar", b.dbase.DisplayName(owner), realName)
|
||||
return caldav.Calendar{
|
||||
Path: calHomePath() + localName + "/",
|
||||
// The displayed name is always the plain calendar name (never the
|
||||
@@ -408,9 +408,10 @@ func (b *Backend) sharedDisplayName(requester, owner, realName string) string {
|
||||
if err != nil {
|
||||
b.logger.Warn("listing own calendars for disambiguation", "error", err)
|
||||
}
|
||||
ownerLabel := b.dbase.DisplayName(owner)
|
||||
for _, c := range own {
|
||||
if c.Name == realName {
|
||||
return fmt.Sprintf("%s (%s)", realName, owner)
|
||||
return fmt.Sprintf("%s (%s)", realName, ownerLabel)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,7 +424,7 @@ func (b *Backend) sharedDisplayName(requester, owner, realName string) string {
|
||||
continue // the calendar itself, not a collision
|
||||
}
|
||||
if sh.CalendarName == realName {
|
||||
return fmt.Sprintf("%s (%s)", realName, owner)
|
||||
return fmt.Sprintf("%s (%s)", realName, ownerLabel)
|
||||
}
|
||||
}
|
||||
return realName
|
||||
|
||||
Reference in New Issue
Block a user