✨ Trigger fediverse scan by API
This commit is contained in:
		
							
								
								
									
										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"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func MapAPIs(app *fiber.App, baseURL string) {
 | 
			
		||||
func MapControllers(app *fiber.App, baseURL string) {
 | 
			
		||||
	api := app.Group(baseURL).Name("API")
 | 
			
		||||
	{
 | 
			
		||||
		api.Get("/webfinger", getWebfinger)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,12 @@
 | 
			
		||||
package http
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
 | 
			
		||||
	"git.solsynth.dev/hypernet/passport/pkg/authkit"
 | 
			
		||||
	"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"
 | 
			
		||||
	"github.com/gofiber/fiber/v2"
 | 
			
		||||
	"github.com/gofiber/fiber/v2/middleware/cors"
 | 
			
		||||
@@ -59,7 +61,8 @@ func NewServer() *App {
 | 
			
		||||
	app.Use(sec.ContextMiddleware(IReader))
 | 
			
		||||
	app.Use(authkit.ParseAccountMiddleware)
 | 
			
		||||
 | 
			
		||||
	api.MapAPIs(app, "/api")
 | 
			
		||||
	api.MapControllers(app, "/api")
 | 
			
		||||
	admin.MapControllers(app, "/api/admin")
 | 
			
		||||
 | 
			
		||||
	return &App{
 | 
			
		||||
		app: app,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user