👽 Upgrade to new events audit system

This commit is contained in:
2025-03-15 17:18:35 +08:00
parent ce257f83b8
commit 1c927122c2
8 changed files with 66 additions and 69 deletions

View File

@ -2,7 +2,6 @@ package api
import (
"fmt"
"strconv"
"time"
"git.solsynth.dev/hypernet/nexus/pkg/nex/cruda"
@ -105,7 +104,7 @@ func createArticle(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.new",
strconv.Itoa(int(item.ID)),
map[string]interface{}{"post": item},
c,
)
}
@ -209,7 +208,7 @@ func editArticle(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.edit",
strconv.Itoa(int(item.ID)),
map[string]interface{}{"post": item},
c,
)
}

View File

@ -260,7 +260,7 @@ func deletePost(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.delete",
strconv.Itoa(int(item.ID)),
map[string]any{"post": item},
c,
)
}
@ -302,7 +302,7 @@ func reactPost(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.react",
strconv.Itoa(int(res.ID)),
map[string]any{"post_id": res.ID, "reaction": reaction},
c,
)
@ -327,7 +327,7 @@ func pinPost(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.pin",
strconv.Itoa(int(res.ID)),
map[string]any{"post": res},
c,
)
return c.SendStatus(fiber.StatusOK)
@ -335,7 +335,7 @@ func pinPost(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.unpin",
strconv.Itoa(int(res.ID)),
map[string]any{"post": res},
c,
)
return c.SendStatus(fiber.StatusNoContent)

View File

@ -3,7 +3,6 @@ package api
import (
"context"
"fmt"
"strconv"
"time"
"git.solsynth.dev/hypernet/interactive/pkg/internal/database"
@ -148,7 +147,7 @@ func createQuestion(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.new",
strconv.Itoa(int(item.ID)),
map[string]any{"post": item},
c,
)
}
@ -262,7 +261,7 @@ func editQuestion(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.edit",
strconv.Itoa(int(item.ID)),
map[string]any{"post": item},
c,
)
}
@ -344,7 +343,10 @@ func selectQuestionAnswer(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.edit.answer",
strconv.Itoa(int(item.ID)),
map[string]any{
"post": item,
"answer": answer,
},
c,
)
}

View File

@ -2,7 +2,6 @@ package api
import (
"fmt"
"strconv"
"time"
"git.solsynth.dev/hypernet/nexus/pkg/nex/cruda"
@ -127,8 +126,8 @@ func createStory(c *fiber.Ctx) error {
} else {
_ = authkit.AddEventExt(
gap.Nx,
"posts.new",
strconv.Itoa(int(item.ID)),
"posts.edit",
map[string]interface{}{"post": item},
c,
)
}
@ -236,7 +235,7 @@ func editStory(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.edit",
strconv.Itoa(int(item.ID)),
map[string]interface{}{"post": item},
c,
)
}

View File

@ -2,10 +2,10 @@ package api
import (
"fmt"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"git.solsynth.dev/hypernet/passport/pkg/authkit"
authm "git.solsynth.dev/hypernet/passport/pkg/authkit/models"
"strconv"
"git.solsynth.dev/hypernet/interactive/pkg/internal/gap"
"git.solsynth.dev/hypernet/interactive/pkg/internal/services"
@ -98,7 +98,7 @@ func subscribeToUser(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.subscribe.users",
strconv.Itoa(int(otherUser.ID)),
map[string]any{"user": otherUser},
c,
)
@ -125,7 +125,7 @@ func subscribeToTag(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.subscribe.tags",
strconv.Itoa(int(tag.ID)),
map[string]any{"tag": tag},
c,
)
@ -152,7 +152,7 @@ func subscribeToCategory(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.subscribe.categories",
strconv.Itoa(int(category.ID)),
map[string]any{"category": category},
c,
)
@ -179,7 +179,7 @@ func unsubscribeFromUser(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.unsubscribe.users",
strconv.Itoa(int(otherUser.ID)),
map[string]any{"user": otherUser},
c,
)
@ -206,7 +206,7 @@ func unsubscribeFromTag(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.unsubscribe.tags",
strconv.Itoa(int(tag.ID)),
map[string]any{"tag": tag},
c,
)
@ -233,7 +233,7 @@ func unsubscribeFromCategory(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.unsubscribe.categories",
strconv.Itoa(int(category.ID)),
map[string]any{"category": category},
c,
)

View File

@ -2,7 +2,6 @@ package api
import (
"fmt"
"strconv"
"time"
"git.solsynth.dev/hypernet/interactive/pkg/internal/database"
@ -106,7 +105,7 @@ func createVideo(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.new",
strconv.Itoa(int(item.ID)),
map[string]any{"post": item},
c,
)
}
@ -212,7 +211,7 @@ func editVideo(c *fiber.Ctx) error {
_ = authkit.AddEventExt(
gap.Nx,
"posts.edit",
strconv.Itoa(int(item.ID)),
map[string]any{"post": item},
c,
)
}