aboutsummaryrefslogtreecommitdiff
path: root/service/transport.go
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2020-02-02 08:30:40 +0000
committerr <r@freesoftwareextremist.com>2020-02-02 08:30:40 +0000
commit5d58269132a27373ef8932ddcbbbf8b8637fa380 (patch)
treed1bb7dc2dc72a9fb4486d4214a570b3278133b48 /service/transport.go
parent4d9e0af373b3a92d04498070c6fc8f6c197fc9c0 (diff)
downloadbloat-5d58269132a27373ef8932ddcbbbf8b8637fa380.tar.gz
bloat-5d58269132a27373ef8932ddcbbbf8b8637fa380.zip
Add status deletion
Diffstat (limited to 'service/transport.go')
-rw-r--r--service/transport.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/service/transport.go b/service/transport.go
index cc864e7..6316748 100644
--- a/service/transport.go
+++ b/service/transport.go
@@ -290,7 +290,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
ctx := newCtxWithSesion(req)
token := req.URL.Query().Get("code")
- _, err := s.Signin(ctx, c, "", token)
+ _, _, err := s.Signin(ctx, c, "", token)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
s.ServeErrorPage(ctx, c, err)
@@ -513,6 +513,22 @@ func NewHandler(s Service, staticDir string) http.Handler {
w.WriteHeader(http.StatusFound)
}
+ delete := func(w http.ResponseWriter, req *http.Request) {
+ c := newClient(w)
+ ctx := newCtxWithSesionCSRF(req, req.FormValue("csrf_token"))
+ id, _ := mux.Vars(req)["id"]
+
+ err := s.Delete(ctx, c, id)
+ if err != nil {
+ w.WriteHeader(http.StatusInternalServerError)
+ s.ServeErrorPage(ctx, c, err)
+ return
+ }
+
+ w.Header().Add("Location", req.Header.Get("Referer"))
+ w.WriteHeader(http.StatusFound)
+ }
+
signout := func(w http.ResponseWriter, req *http.Request) {
// TODO remove session from database
http.SetCookie(w, &http.Cookie{
@@ -622,6 +638,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
r.HandleFunc("/settings", settings).Methods(http.MethodPost)
r.HandleFunc("/muteconv/{id}", muteConversation).Methods(http.MethodPost)
r.HandleFunc("/unmuteconv/{id}", unMuteConversation).Methods(http.MethodPost)
+ r.HandleFunc("/delete/{id}", delete).Methods(http.MethodPost)
r.HandleFunc("/signout", signout).Methods(http.MethodGet)
r.HandleFunc("/fluoride/like/{id}", fLike).Methods(http.MethodPost)
r.HandleFunc("/fluoride/unlike/{id}", fUnlike).Methods(http.MethodPost)