Download this file
| 1 | package chat |
| 2 | |
| 3 | import ( |
| 4 | "net/http" |
| 5 | |
| 6 | "amadan.net/oficina/equipo/internal/equipo/personapi" |
| 7 | "amadan.net/oficina/equipo/internal/wire" |
| 8 | "github.com/go-chi/chi/v5" |
| 9 | ) |
| 10 | |
| 11 | func (h *HTTP) projectStar(w http.ResponseWriter, r *http.Request, p personapi.PersonPrincipal) { |
| 12 | var in wire.SetProjectStar |
| 13 | if err := readJSON(r, &in); err != nil { |
| 14 | h.fail(w, r, err) |
| 15 | return |
| 16 | } |
| 17 | out, err := h.Store.SetProjectStar(r.Context(), p.Address, chi.URLParam(r, "id"), in.Starred) |
| 18 | if err != nil { |
| 19 | h.fail(w, r, err) |
| 20 | return |
| 21 | } |
| 22 | writeJSON(w, 200, out) |
| 23 | } |
| 24 | |
| 25 | func (h *HTTP) projectDetails(w http.ResponseWriter, r *http.Request, p personapi.PersonPrincipal) { |
| 26 | var in wire.EditProject |
| 27 | if err := readJSON(r, &in); err != nil { |
| 28 | h.fail(w, r, err) |
| 29 | return |
| 30 | } |
| 31 | out, err := h.Store.EditProject(r.Context(), p.Address, chi.URLParam(r, "id"), in) |
| 32 | if err != nil { |
| 33 | h.fail(w, r, err) |
| 34 | return |
| 35 | } |
| 36 | writeJSON(w, 200, out) |
| 37 | } |
| 38 | |
| 39 | func (h *HTTP) projectForgetName(w http.ResponseWriter, r *http.Request, p personapi.PersonPrincipal) { |
| 40 | var in wire.ForgetProjectName |
| 41 | if err := readJSON(r, &in); err != nil { |
| 42 | h.fail(w, r, err) |
| 43 | return |
| 44 | } |
| 45 | if err := h.Store.ForgetProjectName(r.Context(), p.Address, chi.URLParam(r, "id"), in.Name); err != nil { |
| 46 | h.fail(w, r, err) |
| 47 | return |
| 48 | } |
| 49 | w.WriteHeader(http.StatusNoContent) |
| 50 | } |
| 51 | |