diff options
author | FChannel <> | 2022-06-05 15:14:34 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | 3ac22385f2cb2256db718e47f5ae3c6d13353b70 (patch) | |
tree | 49f12c0cc52661f1fd6661baf2f77fbd5c7f71de /activitypub/actor.go | |
parent | 0359d9d410b9ab597ed4a067d767ab59472b0c03 (diff) |
added janny managment for admin board pages
Diffstat (limited to 'activitypub/actor.go')
-rw-r--r-- | activitypub/actor.go | 72 |
1 files changed, 69 insertions, 3 deletions
diff --git a/activitypub/actor.go b/activitypub/actor.go index ea4ff3b..c6283c8 100644 --- a/activitypub/actor.go +++ b/activitypub/actor.go @@ -839,12 +839,10 @@ func (actor Actor) ReportedResp(ctx *fiber.Ctx) error { return util.MakeError(err, "GetReported") } - if hasAuth, err := util.HasAuth(verification[1], actor.Id); !hasAuth { + if hasAuth, _ := util.HasAuth(verification[1], actor.Id); !hasAuth { ctx.Response().Header.SetStatusCode(http.StatusBadRequest) _, err := ctx.Write([]byte("")) return util.MakeError(err, "GetReported") - } else if err != nil { - return util.MakeError(err, "GetReported") } actor, err = GetActorFromDB(actor.Id) @@ -1099,3 +1097,71 @@ func (actor Actor) WantToServePage(page int) (Collection, error) { return collection, nil } + +func (actor Actor) CreateVerification(verify util.Verify) error { + var err error + + if verify.Code, err = util.CreateKey(50); err != nil { + return util.MakeError(err, "CreateVerification") + } + + if err := verify.Create(); err != nil { + return util.MakeError(err, "CreateVerification") + } + + verify.Board = actor.Id + verify.Identifier = verify.Type + + if err := verify.CreateBoardMod(); err != nil { + return util.MakeError(err, "CreateVerification") + } + + return nil +} + +func (actor Actor) DeleteVerification(verify util.Verify) error { + query := `delete from boardaccess where code=$1` + if _, err := config.DB.Exec(query, verify.Code); err != nil { + return util.MakeError(err, "DeleteVerification") + } + + var code string + query = `select verificationcode from crossverification where code=$1` + if err := config.DB.QueryRow(query, verify.Code).Scan(&code); err != nil { + return util.MakeError(err, "DeleteVerification") + } + + query = `delete from crossverification where code=$1` + if _, err := config.DB.Exec(query, verify.Code); err != nil { + return util.MakeError(err, "DeleteVerification") + } + + query = `delete from verification where code=$1` + if _, err := config.DB.Exec(query, code); err != nil { + return util.MakeError(err, "DeleteVerification") + } + + return nil +} + +func (actor Actor) GetJanitors() ([]util.Verify, error) { + var list []util.Verify + + query := `select identifier, code, board, type, label from boardaccess where board=$1 and type='janitor'` + rows, err := config.DB.Query(query, actor.Id) + + if err != nil { + return list, util.MakeError(err, "GetJanitors") + } + + defer rows.Close() + for rows.Next() { + var verify util.Verify + + rows.Scan(&verify.Identifier, &verify.Code, &verify.Board, &verify.Type, &verify.Label) + + list = append(list, verify) + } + + return list, nil +} |