From 91f68ccfb391ee53bfc36f4877ca8d8f63c8faf2 Mon Sep 17 00:00:00 2001 From: r Date: Sat, 16 Jan 2021 09:10:02 +0000 Subject: Add follow request support --- service/transport.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'service/transport.go') diff --git a/service/transport.go b/service/transport.go index 80ad7f1..7ba52a4 100644 --- a/service/transport.go +++ b/service/transport.go @@ -403,6 +403,26 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler { return nil }, CSRF, HTML) + accept := handle(func(c *client) error { + id, _ := mux.Vars(c.Req)["id"] + err := s.Accept(c, id) + if err != nil { + return err + } + redirect(c, c.Req.Header.Get("Referer")) + return nil + }, CSRF, HTML) + + reject := handle(func(c *client) error { + id, _ := mux.Vars(c.Req)["id"] + err := s.Reject(c, id) + if err != nil { + return err + } + redirect(c, c.Req.Header.Get("Referer")) + return nil + }, CSRF, HTML) + mute := handle(func(c *client) error { id, _ := mux.Vars(c.Req)["id"] err := s.Mute(c, id) @@ -634,6 +654,8 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler { r.HandleFunc("/vote/{id}", vote).Methods(http.MethodPost) r.HandleFunc("/follow/{id}", follow).Methods(http.MethodPost) r.HandleFunc("/unfollow/{id}", unfollow).Methods(http.MethodPost) + r.HandleFunc("/accept/{id}", accept).Methods(http.MethodPost) + r.HandleFunc("/reject/{id}", reject).Methods(http.MethodPost) r.HandleFunc("/mute/{id}", mute).Methods(http.MethodPost) r.HandleFunc("/unmute/{id}", unMute).Methods(http.MethodPost) r.HandleFunc("/block/{id}", block).Methods(http.MethodPost) -- cgit v1.2.3