aboutsummaryrefslogtreecommitdiff
path: root/route/routes
diff options
context:
space:
mode:
Diffstat (limited to 'route/routes')
-rw-r--r--route/routes/boardmgmt.go61
1 files changed, 60 insertions, 1 deletions
diff --git a/route/routes/boardmgmt.go b/route/routes/boardmgmt.go
index 4f3f815..ba20a23 100644
--- a/route/routes/boardmgmt.go
+++ b/route/routes/boardmgmt.go
@@ -104,7 +104,66 @@ func BoardDeleteAttach(ctx *fiber.Ctx) error {
}
func BoardMarkSensitive(ctx *fiber.Ctx) error {
- return ctx.SendString("board mark sensitive")
+ var err error
+
+ postID := ctx.Query("id")
+ board := ctx.Query("board")
+
+ _, auth := util.GetPasswordFromSession(ctx)
+
+ if postID == "" || auth == "" {
+ ctx.Response().Header.SetStatusCode(http.StatusBadRequest)
+
+ _, err := ctx.Write([]byte("id or auth empty"))
+ return util.MakeError(err, "BoardDelete")
+ }
+
+ var col activitypub.Collection
+ activity := activitypub.Activity{Id: postID}
+
+ if col, err = activity.GetCollection(); err != nil {
+ return util.MakeError(err, "BoardDelete")
+ }
+
+ var OP string
+ var actor activitypub.Actor
+
+ if len(col.OrderedItems) == 0 {
+ actor, err = activitypub.GetActorByNameFromDB(board)
+
+ if err != nil {
+ return util.MakeError(err, "BoardDelete")
+ }
+ } else {
+ if len(col.OrderedItems[0].InReplyTo) > 0 {
+ OP = col.OrderedItems[0].InReplyTo[0].Id
+ }
+
+ actor.Id = col.OrderedItems[0].Actor
+ }
+
+ if has, _ := util.HasAuth(auth, actor.Id); !has {
+ ctx.Response().Header.SetStatusCode(http.StatusBadRequest)
+
+ _, err := ctx.Write([]byte("does not have auth"))
+ return util.MakeError(err, "BoardDelete")
+ }
+
+ obj := activitypub.ObjectBase{Id: postID}
+
+ if err = obj.MarkSensitive(true); err != nil {
+ return util.MakeError(err, "BoardDelete")
+ }
+
+ if isOP, _ := obj.CheckIfOP(); !isOP && OP != "" {
+ if local, _ := obj.IsLocal(); !local {
+ return ctx.Redirect("/"+board+"/"+util.RemoteShort(OP), http.StatusSeeOther)
+ }
+
+ return ctx.Redirect(OP, http.StatusSeeOther)
+ }
+
+ return ctx.Redirect("/"+board, http.StatusSeeOther)
}
func BoardRemove(ctx *fiber.Ctx) error {