// Copyright 2026 MarketAlly. All rights reserved.
// SPDX-License-Identifier: MIT

package v2

import (
	"net/http"

	"code.gitea.io/gitea/modules/setting"
	"code.gitea.io/gitea/services/context"
)

// VersionResponse contains version information
type VersionResponse struct {
	Version string `json:"version"`
	API     string `json:"api"`
}

// Version returns the Gitea version
func Version(ctx *context.APIContext) {
	ctx.JSON(http.StatusOK, VersionResponse{
		Version: setting.AppVer,
		API:     "v2",
	})
}

// 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,
	})
}
