feat(admin): manual account blocking (suspensions)
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 12s
CI / ui (pull_request) Successful in 45s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m10s
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 12s
CI / ui (pull_request) Successful in 45s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m10s
Operator-driven hard block, the counterpart to the soft high-rate flag: permanent or until a date, with an optional reason chosen from an editable en+ru picklist (snapshotted onto the block). A block forfeits the player's active games (opponent wins, as a resignation) and cancels their open matchmaking games. A backend gate refuses a blocked account on every /api/v1/user/* route except the block-status probe with 403 account_blocked, which threads through the gateway as the Execute result_code; the UI surfaces it as a terminal blocked screen and stops all push/poll. Temporary blocks self-expire; the operator can unblock at any time (lost games stay lost). Sessions are not revoked, so the blocked client can still reach the exempt block-status endpoint. Backend: migration 00003 (account_suspensions + suspension_reasons) + jet regen; account suspension store; game.ForfeitAllForAccount; requireNotSuspended gate + block-status endpoint; admin console block/unblock + Reasons CRUD. Wire: fbs BlockStatus + account.block_status gateway op. UI: blocked screen, app state, transport/codec, i18n. Docs: ARCHITECTURE, FUNCTIONAL(+ru), PRERELEASE (AB).
This commit is contained in:
@@ -86,6 +86,48 @@ func (s *Server) handleUpdateProfile(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, profileResponseFor(acc))
|
||||
}
|
||||
|
||||
// blockStatusResponse reports the caller's current block to the client. Until is an RFC3339 UTC
|
||||
// instant for a temporary block and empty for a permanent one (or when not blocked); Reason is
|
||||
// the operator-set reason resolved to the account's language, empty when none was cited. It is
|
||||
// the one payload a blocked client can still fetch, behind the suspension gate's exemption.
|
||||
type blockStatusResponse struct {
|
||||
Blocked bool `json:"blocked"`
|
||||
Permanent bool `json:"permanent"`
|
||||
Until string `json:"until,omitempty"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// handleBlockStatus reports whether the caller is blocked and, if so, the block's expiry and the
|
||||
// reason resolved to the account's language. The suspension gate exempts this route so a blocked
|
||||
// client can render the terminal blocked screen.
|
||||
func (s *Server) handleBlockStatus(c *gin.Context) {
|
||||
uid, ok := userID(c)
|
||||
if !ok {
|
||||
abortBadRequest(c, "missing identity")
|
||||
return
|
||||
}
|
||||
susp, blocked, err := s.accounts.CurrentSuspension(c.Request.Context(), uid)
|
||||
if err != nil {
|
||||
s.abortErr(c, err)
|
||||
return
|
||||
}
|
||||
resp := blockStatusResponse{Blocked: blocked}
|
||||
if blocked {
|
||||
resp.Permanent = susp.Permanent()
|
||||
if susp.BlockedUntil != nil {
|
||||
resp.Until = susp.BlockedUntil.UTC().Format(time.RFC3339)
|
||||
}
|
||||
// Resolve the reason snapshot to the account's interface language; fall back to English
|
||||
// if the account row cannot be read for some reason.
|
||||
lang := "en"
|
||||
if acc, err := s.accounts.GetByID(c.Request.Context(), uid); err == nil {
|
||||
lang = acc.PreferredLanguage
|
||||
}
|
||||
resp.Reason = susp.LocalizedReason(lang)
|
||||
}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// handleStats returns the caller's lifetime statistics.
|
||||
func (s *Server) handleStats(c *gin.Context) {
|
||||
uid, ok := userID(c)
|
||||
|
||||
Reference in New Issue
Block a user