aboutsummaryrefslogtreecommitdiff
path: root/route/routes
diff options
context:
space:
mode:
authorFChannel <>2022-06-13 22:23:36 -0700
committerFChannel <>2022-06-19 12:53:29 -0700
commitcb9a6cf7fcf379202f2ccfc4776daf4dd1d35b9d (patch)
tree327795adf7020993b1356961cf5ba869fbb99d02 /route/routes
parent5cff4d3740eb8b9f67de9713124e84109d04cff8 (diff)
admin update board summary form
Diffstat (limited to 'route/routes')
-rw-r--r--route/routes/admin.go31
1 files changed, 30 insertions, 1 deletions
diff --git a/route/routes/admin.go b/route/routes/admin.go
index a2b4ad5..c198e21 100644
--- a/route/routes/admin.go
+++ b/route/routes/admin.go
@@ -355,6 +355,36 @@ func AdminAddJanny(ctx *fiber.Ctx) error {
return ctx.Redirect("/"+config.Key+"/"+redirect, http.StatusSeeOther)
}
+func AdminEditSummary(ctx *fiber.Ctx) error {
+ id, pass := util.GetPasswordFromSession(ctx)
+ actor, _ := webfinger.GetActorFromPath(ctx.Path(), "/"+config.Key+"/")
+
+ if actor.Id == "" {
+ actor, _ = activitypub.GetActorByNameFromDB(config.Domain)
+ }
+
+ hasAuth, _type := util.HasAuth(pass, actor.Id)
+
+ if !hasAuth || _type != "admin" || (id != actor.Id && id != config.Domain) {
+ return util.MakeError(errors.New("Error"), "AdminEditSummary")
+ }
+
+ summary := ctx.FormValue("summary")
+
+ query := `update actor set summary=$1 where id=$2`
+ if _, err := config.DB.Exec(query, summary, actor.Id); err != nil {
+ return util.MakeError(err, "AdminEditSummary")
+ }
+
+ var redirect string
+ if actor.Name != "main" {
+ redirect = actor.Name
+ }
+
+ return ctx.Redirect("/"+config.Key+"/"+redirect, http.StatusSeeOther)
+
+}
+
func AdminDeleteJanny(ctx *fiber.Ctx) error {
id, pass := util.GetPasswordFromSession(ctx)
actor, _ := webfinger.GetActorFromPath(ctx.Path(), "/"+config.Key+"/")
@@ -377,7 +407,6 @@ func AdminDeleteJanny(ctx *fiber.Ctx) error {
}
var redirect string
- actor, _ = webfinger.GetActorFromPath(ctx.Path(), "/"+config.Key+"/")
if actor.Name != "main" {
redirect = actor.Name