This commit is contained in:
@@ -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}}
|
||||
|
||||
Reference in New Issue
Block a user