(app *App, u *User, w http.ResponseWriter, r *http.Request)
| 59 | } |
| 60 | |
| 61 | func handleViewUserInvites(app *App, u *User, w http.ResponseWriter, r *http.Request) error { |
| 62 | // Don't show page if instance doesn't allow it |
| 63 | if !(app.cfg.App.UserInvites != "" && (u.IsAdmin() || app.cfg.App.UserInvites != "admin")) { |
| 64 | return impart.HTTPError{http.StatusNotFound, ""} |
| 65 | } |
| 66 | |
| 67 | f, _ := getSessionFlashes(app, w, r, nil) |
| 68 | |
| 69 | p := struct { |
| 70 | *UserPage |
| 71 | Invites *[]Invite |
| 72 | Silenced bool |
| 73 | }{ |
| 74 | UserPage: NewUserPage(app, r, u, "Invite People", f), |
| 75 | } |
| 76 | |
| 77 | var err error |
| 78 | |
| 79 | p.Silenced, err = app.db.IsUserSilenced(u.ID) |
| 80 | if err != nil { |
| 81 | if err == ErrUserNotFound { |
| 82 | return err |
| 83 | } |
| 84 | log.Error("view invites: %v", err) |
| 85 | } |
| 86 | |
| 87 | p.Invites, err = app.db.GetUserInvites(u.ID) |
| 88 | if err != nil { |
| 89 | return err |
| 90 | } |
| 91 | for i := range *p.Invites { |
| 92 | (*p.Invites)[i].uses = app.db.GetUsersInvitedCount((*p.Invites)[i].ID) |
| 93 | } |
| 94 | |
| 95 | showUserPage(w, "invite", p) |
| 96 | return nil |
| 97 | } |
| 98 | |
| 99 | func handleCreateUserInvite(app *App, u *User, w http.ResponseWriter, r *http.Request) error { |
| 100 | muVal := r.FormValue("uses") |
nothing calls this directly
no test coverage detected