oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package equipo
2
3import (
4 "context"
5 "net/http"
6 "strconv"
7 "strings"
8
9 "amadan.net/oficina/equipo/internal/wire"
10 "github.com/go-chi/chi/v5"
11)
12
13func (a *application) workAddProject(w http.ResponseWriter, r *http.Request) {
14 a.chatActionTo(w, r, "/projects", func(ctx context.Context, address string) error {
15 _, _, err := a.store.Chat().AddProject(ctx, address, r.PostFormValue("repo"))
16 return err
17 })
18}
19
20func (a *application) workProjectDetails(w http.ResponseWriter, r *http.Request) {
21 id := chi.URLParam(r, "id")
22 a.chatActionTo(w, r, "/projects/"+id, func(ctx context.Context, address string) error {
23 revision, err := strconv.ParseInt(r.PostFormValue("revision"), 10, 64)
24 if err != nil {
25 return ErrInvalid
26 }
27 var names []string
28 if text := strings.TrimSpace(r.PostFormValue("names")); text != "" {
29 names = strings.Split(text, ",")
30 }
31 _, err = a.store.Chat().EditProject(ctx, address, id, wire.EditProject{UseTitle: r.PostFormValue("use_title") == "1", Revision: revision, Title: r.PostFormValue("title"), Description: r.PostFormValue("description"), Names: names})
32 return err
33 })
34}
35
36func (a *application) workForgetProjectName(w http.ResponseWriter, r *http.Request) {
37 id := chi.URLParam(r, "id")
38 a.chatActionTo(w, r, "/projects/"+id, func(ctx context.Context, address string) error {
39 return a.store.Chat().ForgetProjectName(ctx, address, id, r.PostFormValue("name"))
40 })
41}
42