✨ Trigger fediverse scan by API
This commit is contained in:
parent
951713b37f
commit
f0216bf770
17
pkg/internal/http/admin/fediverse_api.go
Normal file
17
pkg/internal/http/admin/fediverse_api.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.solsynth.dev/hypernet/interactive/pkg/internal/services"
|
||||||
|
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func adminTriggerFediverseFetch(c *fiber.Ctx) error {
|
||||||
|
if err := sec.EnsureGrantedPerm(c, "AdminTriggerFediverseFetch", true); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
go services.FetchFediverseTimedTask()
|
||||||
|
|
||||||
|
return c.SendStatus(fiber.StatusOK)
|
||||||
|
}
|
10
pkg/internal/http/admin/index.go
Normal file
10
pkg/internal/http/admin/index.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package admin
|
||||||
|
|
||||||
|
import "github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
|
func MapControllers(app *fiber.App, baseURL string) {
|
||||||
|
admin := app.Group(baseURL)
|
||||||
|
{
|
||||||
|
admin.Post("/fediverse", adminTriggerFediverseFetch)
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func MapAPIs(app *fiber.App, baseURL string) {
|
func MapControllers(app *fiber.App, baseURL string) {
|
||||||
api := app.Group(baseURL).Name("API")
|
api := app.Group(baseURL).Name("API")
|
||||||
{
|
{
|
||||||
api.Get("/webfinger", getWebfinger)
|
api.Get("/webfinger", getWebfinger)
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package http
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
|
||||||
"git.solsynth.dev/hypernet/passport/pkg/authkit"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
||||||
|
"git.solsynth.dev/hypernet/passport/pkg/authkit"
|
||||||
|
|
||||||
|
"git.solsynth.dev/hypernet/interactive/pkg/internal/http/admin"
|
||||||
"git.solsynth.dev/hypernet/interactive/pkg/internal/http/api"
|
"git.solsynth.dev/hypernet/interactive/pkg/internal/http/api"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/gofiber/fiber/v2/middleware/cors"
|
"github.com/gofiber/fiber/v2/middleware/cors"
|
||||||
@ -59,7 +61,8 @@ func NewServer() *App {
|
|||||||
app.Use(sec.ContextMiddleware(IReader))
|
app.Use(sec.ContextMiddleware(IReader))
|
||||||
app.Use(authkit.ParseAccountMiddleware)
|
app.Use(authkit.ParseAccountMiddleware)
|
||||||
|
|
||||||
api.MapAPIs(app, "/api")
|
api.MapControllers(app, "/api")
|
||||||
|
admin.MapControllers(app, "/api/admin")
|
||||||
|
|
||||||
return &App{
|
return &App{
|
||||||
app: app,
|
app: app,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user