From 9d937e6f895ca7213ae759efca9b292a1d014ab3 Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Thu, 3 Jun 2021 01:19:37 -0700 Subject: cleaning up removing posts --- main.go | 77 ++++++++++++++++++++++++++--------------------------------------- 1 file changed, 31 insertions(+), 46 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 1be79e1..5e4c69e 100644 --- a/main.go +++ b/main.go @@ -739,40 +739,29 @@ func main() { OP = col.OrderedItems[0].InReplyTo[0].Id } - if !IsIDLocal(db, id) { - CloseLocalReportDB(db, id, board) - CreateLocalDeleteDB(db, id, "post") - if(manage == "t") { - http.Redirect(w, r, "/" + *Key + "/" + board, http.StatusSeeOther) - } else if(OP != ""){ - http.Redirect(w, r, "/" + board + "/" + remoteShort(OP), http.StatusSeeOther) - } else { - http.Redirect(w, r, "/" + board, http.StatusSeeOther) - } - - return + if !isOP { + SetObject(db, id, "Removed") + } else { + SetObjectAndReplies(db, id, "Removed") } - if !isOP { - DeleteReportActivity(db, id) - DeleteObjectRequest(db, id) - DeleteObject(db, obj.Id) - if(manage == "t"){ - http.Redirect(w, r, "/" + *Key + "/" + board , http.StatusSeeOther) - }else{ + if IsIDLocal(db, id){ + DeleteObjectRequest(db, id) + } + + if(manage == "t"){ + http.Redirect(w, r, "/" + *Key + "/" + board , http.StatusSeeOther) + return + } else if !isOP { + if (!IsIDLocal(db, id)){ + http.Redirect(w, r, "/" + board + "/" + remoteShort(OP), http.StatusSeeOther) + return + } else { http.Redirect(w, r, OP, http.StatusSeeOther) + return } - return - } else { - DeleteReportActivity(db, id) - DeleteObjectAndRepliesRequest(db, id) - DeleteObjectAndReplies(db, obj.Id) - if(manage == "t"){ - http.Redirect(w, r, "/" + *Key + "/" + board , http.StatusSeeOther) - }else{ - http.Redirect(w, r, "/" + board, http.StatusSeeOther) - } + http.Redirect(w, r, "/" + board, http.StatusSeeOther) return } @@ -809,26 +798,22 @@ func main() { return } - - - if !IsIDLocal(db, id) { - CreateLocalDeleteDB(db, id, "attachment") - 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) - - if(manage == "t") { + SetAttachmentFromDB(db, id, "Removed") + SetPreviewFromDB(db, id, "Removed") + + if (manage == "t") { http.Redirect(w, r, "/" + *Key + "/" + board, http.StatusSeeOther) - } else { + return + } else if !IsIDLocal(db, OP) { + http.Redirect(w, r, "/" + board + "/" + remoteShort(OP), http.StatusSeeOther) + return + } else { http.Redirect(w, r, OP, http.StatusSeeOther) + return } + + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte("")) }) http.HandleFunc("/report", func(w http.ResponseWriter, r *http.Request){ -- cgit v1.2.3