MCPcopy
hub / github.com/writefreely/writefreely / handleViewUserInvites

Function handleViewUserInvites

invites.go:61–97  ·  view source on GitHub ↗
(app *App, u *User, w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

59}
60
61func 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
99func handleCreateUserInvite(app *App, u *User, w http.ResponseWriter, r *http.Request) error {
100 muVal := r.FormValue("uses")

Callers

nothing calls this directly

Calls 7

getSessionFlashesFunction · 0.85
NewUserPageFunction · 0.85
showUserPageFunction · 0.85
IsAdminMethod · 0.80
IsUserSilencedMethod · 0.80
GetUserInvitesMethod · 0.65
GetUsersInvitedCountMethod · 0.65

Tested by

no test coverage detected