fix(admin): keep account photos out of the media library
Test / test (push) Successful in 8m35s

This commit is contained in:
2026-09-29 23:47:27 +02:00
parent ba6416623f
commit 81d22b24a7
8 changed files with 233 additions and 15 deletions
+19
View File
@@ -19,6 +19,25 @@ func (a *Admin) registerMediaRoutes(mux *http.ServeMux) {
func (a *Admin) handleMediaLibrary(w http.ResponseWriter, r *http.Request) {
data := a.pageData(r)
items := a.deps.Store.ListMedia()
// A profile photo of any account is not library content. Avatars
// stored since the avatar directory existed never reach this list
// at all; the filter keeps the flat photos of installations that
// predate it out of the tiles the same way.
photos := make(map[string]bool)
for _, user := range a.deps.Users.All() {
if user.Photo != "" {
photos[user.Photo] = true
}
}
if len(photos) > 0 {
filtered := items[:0]
for _, item := range items {
if !photos[item.URL] {
filtered = append(filtered, item)
}
}
items = filtered
}
data.MediaItems = mediaRows(items)
data.MediaTotal = humanSize(totalSize(items))
data.Crumbs = []Crumb{{Label: "Media", IsLast: true, UI: true}}