Some checks failed
Build and Release / Create Release (push) Has been skipped
Build and Release / Unit Tests (push) Successful in 3m22s
Build and Release / Build Binaries (amd64, darwin, macos) (push) Has been cancelled
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Has been cancelled
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Has been cancelled
Build and Release / Build Binaries (arm64, darwin, macos) (push) Has been cancelled
Build and Release / Build Binary (linux/arm64) (push) Has been cancelled
Build and Release / Lint (push) Has been cancelled
Build and Release / Integration Tests (PostgreSQL) (push) Has been cancelled
Include loaded plugin details (name, version, description) in /api/v2/version response when plugins are enabled. Also add page class to AI learning admin templates for consistent styling.
57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
// Copyright 2026 MarketAlly. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package v2
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"code.gitcaddy.com/server/v3/modules/plugins"
|
|
"code.gitcaddy.com/server/v3/modules/setting"
|
|
"code.gitcaddy.com/server/v3/services/context"
|
|
)
|
|
|
|
// VersionPluginInfo is a summary of a loaded plugin.
|
|
type VersionPluginInfo struct {
|
|
Name string `json:"name"`
|
|
Version string `json:"version"`
|
|
Description string `json:"description"`
|
|
}
|
|
|
|
// VersionResponse contains version information
|
|
type VersionResponse struct {
|
|
Version string `json:"version"`
|
|
API string `json:"api"`
|
|
Plugins []VersionPluginInfo `json:"plugins,omitempty"`
|
|
}
|
|
|
|
// Version returns the server version and loaded plugins
|
|
func Version(ctx *context.APIContext) {
|
|
resp := VersionResponse{
|
|
Version: setting.AppVer,
|
|
API: "v2",
|
|
}
|
|
|
|
if setting.Plugins.Enabled {
|
|
for _, p := range plugins.All() {
|
|
resp.Plugins = append(resp.Plugins, VersionPluginInfo{
|
|
Name: p.Name(),
|
|
Version: p.Version(),
|
|
Description: p.Description(),
|
|
})
|
|
}
|
|
}
|
|
|
|
ctx.JSON(http.StatusOK, resp)
|
|
}
|
|
|
|
// GetAuthenticatedUser returns the authenticated user
|
|
func GetAuthenticatedUser(ctx *context.APIContext) {
|
|
ctx.JSON(http.StatusOK, map[string]any{
|
|
"id": ctx.Doer.ID,
|
|
"login": ctx.Doer.Name,
|
|
"email": ctx.Doer.Email,
|
|
"is_admin": ctx.Doer.IsAdmin,
|
|
})
|
|
}
|