58 lines
2.0 KiB
Go
58 lines
2.0 KiB
Go
package api
|
|
|
|
import (
|
|
"browser.local/platform/domain"
|
|
"browser.local/platform/dto"
|
|
"browser.local/platform/repo"
|
|
"net/http"
|
|
"strconv"
|
|
)
|
|
|
|
// serverGamePlayers godoc
|
|
// @Summary List server-local game players
|
|
// @Description Returns privacy-safe SCUM game player records visible to the current server operator.
|
|
// @Tags game-players
|
|
// @Produce json
|
|
// @Success 200 {object} dto.GamePlayerListResponse
|
|
// @Failure 401 {object} dto.ErrorResponse
|
|
// @Failure 403 {object} dto.ErrorResponse
|
|
// @Router /api/v1/server-instances/{id}/game-players [get]
|
|
func (h *coreHandlers) serverGamePlayers(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method != http.MethodGet {
|
|
writeMethodNotAllowed(w, http.MethodGet)
|
|
return
|
|
}
|
|
limit, _ := strconv.Atoi(r.URL.Query().Get("limit"))
|
|
values, err := h.core.ListGamePlayersForSession(bearerToken(r), domain.GamePlayerFilter{ServerInstanceID: r.PathValue("id"), Search: r.URL.Query().Get("search"), Limit: limit})
|
|
if err != nil {
|
|
writeServiceError(w, err)
|
|
return
|
|
}
|
|
writeJSON(w, http.StatusOK, dto.GamePlayerListFromDomain(values))
|
|
}
|
|
|
|
// serverGamePlayerDetail godoc
|
|
// @Summary Get server-local game player profile
|
|
// @Description Returns aliases, session trajectory, access attempts, and manual-review signals without network identifiers.
|
|
// @Tags game-players
|
|
// @Produce json
|
|
// @Success 200 {object} dto.GamePlayerProfileResponse
|
|
// @Failure 404 {object} dto.ErrorResponse
|
|
// @Router /api/v1/server-instances/{id}/game-players/{playerId} [get]
|
|
func (h *coreHandlers) serverGamePlayerDetail(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method != http.MethodGet {
|
|
writeMethodNotAllowed(w, http.MethodGet)
|
|
return
|
|
}
|
|
value, err := h.core.GetGamePlayerProfileForSession(bearerToken(r), r.PathValue("playerId"))
|
|
if err != nil {
|
|
writeServiceError(w, err)
|
|
return
|
|
}
|
|
if value.Player.ServerInstanceID != r.PathValue("id") {
|
|
writeServiceError(w, repo.ErrNotFound)
|
|
return
|
|
}
|
|
writeJSON(w, http.StatusOK, dto.GamePlayerProfileFromDomain(value))
|
|
}
|