(app *App, u *User, w http.ResponseWriter, r *http.Request)
| 816 | } |
| 817 | |
| 818 | func viewCollections(app *App, u *User, w http.ResponseWriter, r *http.Request) error { |
| 819 | c, err := app.db.GetCollections(u, app.cfg.App.Host) |
| 820 | if err != nil { |
| 821 | log.Error("unable to fetch collections: %v", err) |
| 822 | return fmt.Errorf("No collections") |
| 823 | } |
| 824 | |
| 825 | f, _ := getSessionFlashes(app, w, r, nil) |
| 826 | |
| 827 | uc, _ := app.db.GetUserCollectionCount(u.ID) |
| 828 | // TODO: handle any errors |
| 829 | |
| 830 | silenced, err := app.db.IsUserSilenced(u.ID) |
| 831 | if err != nil { |
| 832 | if err == ErrUserNotFound { |
| 833 | return err |
| 834 | } |
| 835 | log.Error("view collections: %v", err) |
| 836 | return fmt.Errorf("view collections: %v", err) |
| 837 | } |
| 838 | d := struct { |
| 839 | *UserPage |
| 840 | Collections *[]Collection |
| 841 | |
| 842 | UsedCollections, TotalCollections int |
| 843 | |
| 844 | NewBlogsDisabled bool |
| 845 | Silenced bool |
| 846 | }{ |
| 847 | UserPage: NewUserPage(app, r, u, u.Username+"'s Blogs", f), |
| 848 | Collections: c, |
| 849 | UsedCollections: int(uc), |
| 850 | NewBlogsDisabled: !app.cfg.App.CanCreateBlogs(uc), |
| 851 | Silenced: silenced, |
| 852 | } |
| 853 | d.UserPage.SetMessaging(u) |
| 854 | showUserPage(w, "collections", d) |
| 855 | |
| 856 | return nil |
| 857 | } |
| 858 | |
| 859 | func viewEditCollection(app *App, u *User, w http.ResponseWriter, r *http.Request) error { |
| 860 | vars := mux.Vars(r) |
nothing calls this directly
no test coverage detected