aboutsummaryrefslogtreecommitdiff
path: root/routes/admin.go
diff options
context:
space:
mode:
authorFChannel <>2022-05-03 22:42:24 -0700
committerFChannel <>2022-06-19 12:53:29 -0700
commit493fc8e025fd613d9faf0b573d610e4a0e0c0228 (patch)
treefd7f217ca407c1aa8e584db26d0a95944c23b034 /routes/admin.go
parent328c9150228156c04d1045469c7dbcd7b5f4fedf (diff)
creating boards works
Diffstat (limited to 'routes/admin.go')
-rw-r--r--routes/admin.go42
1 files changed, 37 insertions, 5 deletions
diff --git a/routes/admin.go b/routes/admin.go
index e80d24f..580b4dd 100644
--- a/routes/admin.go
+++ b/routes/admin.go
@@ -169,7 +169,7 @@ func AdminFollow(ctx *fiber.Ctx) error {
col.Items = append(col.Items, nObj)
for _, e := range col.Items {
- if isFollowing, _ := activitypub.IsAlreadyFollowing(actorId, e.Id); isFollowing && e.Id != config.Domain && e.Id != actorId {
+ if isFollowing, _ := activitypub.IsAlreadyFollowing(actorId, e.Id); !isFollowing && e.Id != config.Domain && e.Id != actorId {
followActivity, _ := db.MakeFollowActivity(actorId, e.Id)
if actor, _ := webfinger.FingerActor(e.Id); actor.Id != "" {
@@ -189,7 +189,7 @@ func AdminFollow(ctx *fiber.Ctx) error {
col.Items = append(col.Items, nObj)
for _, e := range col.Items {
- if isFollowing, _ := activitypub.IsAlreadyFollowing(actorId, e.Id); isFollowing && e.Id != config.Domain && e.Id != actorId {
+ if isFollowing, _ := activitypub.IsAlreadyFollowing(actorId, e.Id); !isFollowing && e.Id != config.Domain && e.Id != actorId {
followActivity, _ := db.MakeFollowActivity(actorId, e.Id)
if actor, _ := webfinger.FingerActor(e.Id); actor.Id != "" {
db.MakeActivityRequestOutbox(followActivity)
@@ -220,10 +220,42 @@ func AdminFollow(ctx *fiber.Ctx) error {
return ctx.Redirect("/"+config.Key+"/"+redirect, http.StatusSeeOther)
}
-func AdminAddBoard(c *fiber.Ctx) error {
- // STUB
+func AdminAddBoard(ctx *fiber.Ctx) error {
+ actor, _ := activitypub.GetActorFromDB(config.Domain)
+
+ if hasValidation := db.HasValidation(ctx, actor); !hasValidation {
+ return nil
+ }
+
+ var newActorActivity activitypub.Activity
+ var board activitypub.Actor
+
+ var restrict bool
+ if ctx.FormValue("restricted") == "True" {
+ restrict = true
+ } else {
+ restrict = false
+ }
+
+ board.Name = ctx.FormValue("name")
+ board.PreferredUsername = ctx.FormValue("prefname")
+ board.Summary = ctx.FormValue("summary")
+ board.Restricted = restrict
+
+ newActorActivity.AtContext.Context = "https://www.w3.org/ns/activitystreams"
+ newActorActivity.Type = "New"
+
+ var nobj activitypub.ObjectBase
+ newActorActivity.Actor = &actor
+ newActorActivity.Object = &nobj
+
+ newActorActivity.Object.Alias = board.Name
+ newActorActivity.Object.Name = board.PreferredUsername
+ newActorActivity.Object.Summary = board.Summary
+ newActorActivity.Object.Sensitive = board.Restricted
- return c.SendString("admin add board")
+ db.MakeActivityRequestOutbox(newActorActivity)
+ return ctx.Redirect("/"+config.Key, http.StatusSeeOther)
}
func AdminPostNews(c *fiber.Ctx) error {