package handlers import ( "net/http" "warpbox.dev/backend/libs/services" "warpbox.dev/backend/libs/web" ) type homeData struct { MaxUploadSize string Collections []collectionView IsAdmin bool } func (a *App) Home(w http.ResponseWriter, r *http.Request) { currentUser := a.currentPublicUser(r) var collections []collectionView var isAdmin bool if user, ok := a.currentUser(r); ok { isAdmin = user.Role == services.UserRoleAdmin userCollections, err := a.authService.ListCollections(user.ID) if err == nil { collections = make([]collectionView, 0, len(userCollections)) for _, collection := range userCollections { collections = append(collections, collectionView{ID: collection.ID, Name: collection.Name}) } } } a.renderer.Render(w, http.StatusOK, "home.html", web.PageData{ Title: "Upload your files", Description: "Upload and share files through a self-hosted Warpbox instance.", CurrentUser: currentUser, Data: homeData{ MaxUploadSize: a.uploadService.MaxUploadSizeLabel(), Collections: collections, IsAdmin: isAdmin, }, }) }