mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
Fixes #9282 Adds a new admin panel category for federation related administration. Includes views for: - Instance Federation Configuration - List of Federation Hosts - (Per-Instance) List of Federated Users Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11115 Reviewed-by: elle <0xllx0@noreply.codeberg.org> Reviewed-by: Panagiotis "Ivory" Vasilopoulos <git@n0toose.net> Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Florian Pallas <mail@fpallas.com> Co-committed-by: Florian Pallas <mail@fpallas.com>
58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
// Copyright 2026 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package admin
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"forgejo.org/models/db"
|
|
"forgejo.org/models/forgefed"
|
|
"forgejo.org/modules/base"
|
|
"forgejo.org/modules/setting"
|
|
"forgejo.org/services/context"
|
|
)
|
|
|
|
const (
|
|
tplFederationHosts base.TplName = "admin/federation/hosts"
|
|
)
|
|
|
|
func FederationHosts(ctx *context.Context) {
|
|
sort := ctx.FormTrim("sort")
|
|
page := ctx.FormInt("page")
|
|
if page < 1 {
|
|
page = 1
|
|
}
|
|
|
|
hosts, err := forgefed.FindFederationHosts(ctx, db.ListOptions{
|
|
Page: page,
|
|
PageSize: setting.UI.Admin.FederationHostPagingNum,
|
|
})
|
|
if err != nil {
|
|
ctx.ServerError("GetFederationHosts", err)
|
|
return
|
|
}
|
|
|
|
total, err := forgefed.CountFederationHosts(ctx)
|
|
if err != nil {
|
|
ctx.ServerError("CountFederationHosts", err)
|
|
return
|
|
}
|
|
|
|
ctx.Data["Title"] = ctx.Tr("admin.federation.hosts.title")
|
|
ctx.Data["PageIsAdminFederationHosts"] = true
|
|
ctx.Data["SortType"] = sort
|
|
ctx.Data["TotalCount"] = int(total)
|
|
ctx.Data["Hosts"] = hosts
|
|
|
|
numPages := 0
|
|
if total > 0 {
|
|
numPages = (int(total) - 1/setting.UI.Admin.FederationHostPagingNum)
|
|
}
|
|
|
|
pager := context.NewPagination(int(total), setting.UI.Admin.FederationHostPagingNum, page, numPages)
|
|
pager.SetDefaultParams(ctx)
|
|
ctx.Data["Page"] = pager
|
|
|
|
ctx.HTML(http.StatusOK, tplFederationHosts)
|
|
}
|