diff options
author | FChannel <> | 2021-05-30 21:40:04 -0700 |
---|---|---|
committer | FChannel <> | 2021-05-30 21:40:04 -0700 |
commit | caa24b5f43709f3201faf0eabf2ac7afcdee17f7 (patch) | |
tree | d9395c0071fa0ee5fd73177cc944145a353a4c10 | |
parent | 869b0262ac1c69fe41cc8d6bc59bd47f6e48f685 (diff) |
more route redirection cleanup
-rw-r--r-- | main.go | 58 | ||||
-rw-r--r-- | static/bottom.html | 2 | ||||
-rw-r--r-- | static/manage.html | 2 | ||||
-rw-r--r-- | static/posts.html | 8 |
4 files changed, 46 insertions, 24 deletions
@@ -187,6 +187,7 @@ func main() { page, _ := strconv.Atoi(postNum) collection, valid := WantToServePage(db, actor.Name, page) + if valid { OutboxGet(w, r, db, collection) } @@ -710,6 +711,7 @@ func main() { http.HandleFunc("/delete", func(w http.ResponseWriter, r *http.Request){ id := r.URL.Query().Get("id") + manage := r.URL.Query().Get("manage") board := r.URL.Query().Get("board") col := GetCollectionFromID(id) actor := col.OrderedItems[0].Actor @@ -727,37 +729,43 @@ func main() { return } + var obj ObjectBase + obj.Id = id + obj.Actor = actor + + isOP := CheckIfObjectOP(db, obj.Id) + var OP string if len(col.OrderedItems[0].InReplyTo) > 0 { OP = col.OrderedItems[0].InReplyTo[0].Id } if !IsIDLocal(db, id) { - CreateLocalDeleteDB(db, id, "post") - CloseLocalReportDB(db, id, actor.Id) - - if(board != "") { - http.Redirect(w, r, "/" + *Key + "/" + board , http.StatusSeeOther) + if(!isOP) { + CloseLocalReportDB(db, id, board) + CreateLocalDeleteDB(db, id, "post") + } else { + + } + if(manage == "t") { + http.Redirect(w, r, "/" + *Key + "/" + board, http.StatusSeeOther) } else if(OP != ""){ - http.Redirect(w, r, OP, http.StatusSeeOther) + http.Redirect(w, r, "/" + board + "/" + remoteShort(OP), http.StatusSeeOther) } else { - http.Redirect(w, r, actor.Id, http.StatusSeeOther) + http.Redirect(w, r, "/" + board, http.StatusSeeOther) } return } - var obj ObjectBase - obj.Id = id - obj.Actor = actor - - isOP := CheckIfObjectOP(db, obj.Id) + if !isOP { + DeleteReportActivity(db, id) DeleteObjectRequest(db, id) DeleteObject(db, obj.Id) - if(board != ""){ + if(manage == "t"){ http.Redirect(w, r, "/" + *Key + "/" + board , http.StatusSeeOther) }else{ http.Redirect(w, r, OP, http.StatusSeeOther) @@ -765,12 +773,13 @@ func main() { return } else { + DeleteReportActivity(db, id) DeleteObjectAndRepliesRequest(db, id) DeleteObjectAndReplies(db, obj.Id) - if(board != ""){ + if(manage == "t"){ http.Redirect(w, r, "/" + *Key + "/" + board , http.StatusSeeOther) }else{ - http.Redirect(w, r, actor.Id, http.StatusSeeOther) + http.Redirect(w, r, "/" + board, http.StatusSeeOther) } return } @@ -782,6 +791,8 @@ func main() { http.HandleFunc("/deleteattach", func(w http.ResponseWriter, r *http.Request){ id := r.URL.Query().Get("id") + manage := r.URL.Query().Get("manage") + board := r.URL.Query().Get("board") col := GetCollectionFromID(id) actor := col.OrderedItems[0].Actor @@ -804,17 +815,28 @@ func main() { w.WriteHeader(http.StatusBadRequest) w.Write([]byte("")) return - } + } + + if !IsIDLocal(db, id) { CreateLocalDeleteDB(db, id, "attachment") - http.Redirect(w, r, OP, http.StatusSeeOther) + if(manage == "t") { + http.Redirect(w, r, "/" + *Key + "/" + board, http.StatusSeeOther) + } else { + http.Redirect(w, r, "/" + board + "/" + remoteShort(OP), http.StatusSeeOther) + } return } DeleteAttachmentFromFile(db, id) DeletePreviewFromFile(db, id) - http.Redirect(w, r, OP, http.StatusSeeOther) + + if(manage == "t") { + http.Redirect(w, r, "/" + *Key + "/" + board, http.StatusSeeOther) + } else { + http.Redirect(w, r, OP, http.StatusSeeOther) + } }) http.HandleFunc("/report", func(w http.ResponseWriter, r *http.Request){ diff --git a/static/bottom.html b/static/bottom.html index c058b14..8774419 100644 --- a/static/bottom.html +++ b/static/bottom.html @@ -29,7 +29,7 @@ <input id="report-submit" type="submit" value="Report" style="float: right;"> <input type="hidden" id="report-inReplyTo-box" name="id" value="{{ .Board.InReplyTo }}"> <input type="hidden" id="sendTo" name="sendTo" value="{{ .Board.To }}"> - <input type="hidden" id="boardName" name="boardName" value="{{ .Board.Name }}"> + <input type="hidden" id="boardName" name="board" value="{{ .Board.Name }}"> <input type="hidden" name="close" value="0"> <input type="hidden" id="captchaCode" name="captchaCode" value="{{ .Board.CaptchaCode }}"> <div style="width: 202px; margin: 0 auto; padding-top: 12px;"> diff --git a/static/manage.html b/static/manage.html index 9578f8a..4fb417f 100644 --- a/static/manage.html +++ b/static/manage.html @@ -50,7 +50,7 @@ <ul style="display: inline-block; padding: 0; margin: 0; list-style-type: none;"> {{ $domain := .Domain }} {{ range .Reported }} - <li><a id="rpost" post="{{ .ID }}" href=""></a> - <b>{{ .Count }}</b> <a href="/delete?id={{ .ID }}&board={{ $board.Name }}">[Remove Post]</a> <a href="/deleteattach?id={{ .ID }}">[Remove Attachment]</a> <a href="/report?id={{ .ID }}&close=1&board={{ $board.Name }}">[Close]</a></li> + <li><a id="rpost" post="{{ .ID }}" href=""></a> - <b>{{ .Count }}</b> <a href="/delete?id={{ .ID }}&board={{ $board.Name }}&manage=t">[Remove Post]</a> <a href="/deleteattach?id={{ .ID }}&board={{ $board.Name }}&manage=t">[Remove Attachment]</a> <a href="/report?id={{ .ID }}&close=1&board={{ $board.Name }}">[Close]</a></li> {{ end }} </ul> </div> diff --git a/static/posts.html b/static/posts.html index 7806204..aaf10c9 100644 --- a/static/posts.html +++ b/static/posts.html @@ -9,11 +9,11 @@ <div style="overflow: auto;"> <div id="{{ .Id }}" style="overflow: visible; margin-bottom: 12px;"> {{ if eq $board.ModCred $board.Domain $board.Actor.Id }} - <a href="/delete?id={{ .Id }}">[Delete Post]</a> + <a href="/delete?id={{ .Id }}&board={{ $board.Actor.Name }}">[Delete Post]</a> {{ end }} {{ if .Attachment }} {{ if eq $board.ModCred $board.Domain $board.Actor.Id }} - <a href="/deleteattach?id={{ .Id }}">[Delete Attachment]</a> + <a href="/deleteattach?id={{ .Id }}&board={{ $board.Actor.Name }}">[Delete Attachment]</a> {{ end }} <span style="display: block;">File: <a id="{{ .Id }}-img" href="{{ (index .Attachment 0).Href}}">{{ (index .Attachment 0).Name }}</a><span id="{{ .Id }}-size">({{ (index .Attachment 0).Size }})</span></span> <div id="media-{{ .Id }}"></div> @@ -75,11 +75,11 @@ <div style="float: left; display: block; margin-right: 5px;">>></div> <div class="post" style="overflow: auto; padding: 5px; margin-bottom: 2px;"> {{ if eq $board.ModCred $board.Domain $board.Actor.Id }} - <a href="/delete?id={{ .Id }}">[Delete Post]</a> + <a href="/delete?id={{ .Id }}&board={{ $board.Actor.Name }}">[Delete Post]</a> {{ end }} {{ if .Attachment }} {{ if eq $board.ModCred $board.Domain $board.Actor.Id }} - <a href="/deleteattach?id={{ .Id }}">[Delete Attachment]</a> + <a href="/deleteattach?id={{ .Id }}&board={{ $board.Actor.Id }}">[Delete Attachment]</a> {{ end }} <span style="display: block;">File <a id="{{ .Id }}-img" href="{{ (index .Attachment 0).Href}}">{{ (index .Attachment 0).Name }}</a> <span id="{{ .Id }}-size">({{ (index .Attachment 0).Size }})</span></span> <div id="media-{{ .Id }}"></div> |