MCPcopy
hub / github.com/writefreely/writefreely / viewEditCollection

Function viewEditCollection

account.go:859–898  ·  view source on GitHub ↗
(app *App, u *User, w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

857}
858
859func viewEditCollection(app *App, u *User, w http.ResponseWriter, r *http.Request) error {
860 vars := mux.Vars(r)
861 c, err := app.db.GetCollection(vars["collection"])
862 if err != nil {
863 return err
864 }
865 if c.OwnerID != u.ID {
866 return ErrCollectionNotFound
867 }
868
869 silenced, err := app.db.IsUserSilenced(u.ID)
870 if err != nil {
871 if err == ErrUserNotFound {
872 return err
873 }
874 log.Error("view edit collection %v", err)
875 return fmt.Errorf("view edit collection: %v", err)
876 }
877 flashes, _ := getSessionFlashes(app, w, r, nil)
878 obj := struct {
879 *UserPage
880 *Collection
881 Silenced bool
882
883 config.EmailCfg
884 LetterReplyTo string
885 }{
886 UserPage: NewUserPage(app, r, u, "Edit "+c.DisplayTitle(), flashes),
887 Collection: c,
888 Silenced: silenced,
889 EmailCfg: app.cfg.Email,
890 }
891 obj.UserPage.CollAlias = c.Alias
892 if obj.EmailCfg.Enabled() {
893 obj.LetterReplyTo = app.db.GetCollectionAttribute(c.ID, collAttrLetterReplyTo)
894 }
895
896 showUserPage(w, "collection", obj)
897 return nil
898}
899
900func updateSettings(app *App, w http.ResponseWriter, r *http.Request) error {
901 reqJSON := IsJSON(r)

Callers

nothing calls this directly

Calls 8

getSessionFlashesFunction · 0.85
NewUserPageFunction · 0.85
showUserPageFunction · 0.85
IsUserSilencedMethod · 0.80
EnabledMethod · 0.80
GetCollectionMethod · 0.65
DisplayTitleMethod · 0.45

Tested by

no test coverage detected