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

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:
Ilia Denisov
2026-06-14 21:55:59 +02:00
parent 9d85090075
commit d1ba666495
48 changed files with 2206 additions and 2 deletions
@@ -0,0 +1,99 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var AccountSuspensions = newAccountSuspensionsTable("backend", "account_suspensions", "")
type accountSuspensionsTable struct {
postgres.Table
// Columns
SuspensionID postgres.ColumnString
AccountID postgres.ColumnString
BlockedAt postgres.ColumnTimestampz
BlockedUntil postgres.ColumnTimestampz
ReasonEn postgres.ColumnString
ReasonRu postgres.ColumnString
ReasonID postgres.ColumnString
LiftedAt postgres.ColumnTimestampz
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
DefaultColumns postgres.ColumnList
}
type AccountSuspensionsTable struct {
accountSuspensionsTable
EXCLUDED accountSuspensionsTable
}
// AS creates new AccountSuspensionsTable with assigned alias
func (a AccountSuspensionsTable) AS(alias string) *AccountSuspensionsTable {
return newAccountSuspensionsTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new AccountSuspensionsTable with assigned schema name
func (a AccountSuspensionsTable) FromSchema(schemaName string) *AccountSuspensionsTable {
return newAccountSuspensionsTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new AccountSuspensionsTable with assigned table prefix
func (a AccountSuspensionsTable) WithPrefix(prefix string) *AccountSuspensionsTable {
return newAccountSuspensionsTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new AccountSuspensionsTable with assigned table suffix
func (a AccountSuspensionsTable) WithSuffix(suffix string) *AccountSuspensionsTable {
return newAccountSuspensionsTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newAccountSuspensionsTable(schemaName, tableName, alias string) *AccountSuspensionsTable {
return &AccountSuspensionsTable{
accountSuspensionsTable: newAccountSuspensionsTableImpl(schemaName, tableName, alias),
EXCLUDED: newAccountSuspensionsTableImpl("", "excluded", ""),
}
}
func newAccountSuspensionsTableImpl(schemaName, tableName, alias string) accountSuspensionsTable {
var (
SuspensionIDColumn = postgres.StringColumn("suspension_id")
AccountIDColumn = postgres.StringColumn("account_id")
BlockedAtColumn = postgres.TimestampzColumn("blocked_at")
BlockedUntilColumn = postgres.TimestampzColumn("blocked_until")
ReasonEnColumn = postgres.StringColumn("reason_en")
ReasonRuColumn = postgres.StringColumn("reason_ru")
ReasonIDColumn = postgres.StringColumn("reason_id")
LiftedAtColumn = postgres.TimestampzColumn("lifted_at")
allColumns = postgres.ColumnList{SuspensionIDColumn, AccountIDColumn, BlockedAtColumn, BlockedUntilColumn, ReasonEnColumn, ReasonRuColumn, ReasonIDColumn, LiftedAtColumn}
mutableColumns = postgres.ColumnList{AccountIDColumn, BlockedAtColumn, BlockedUntilColumn, ReasonEnColumn, ReasonRuColumn, ReasonIDColumn, LiftedAtColumn}
defaultColumns = postgres.ColumnList{BlockedAtColumn}
)
return accountSuspensionsTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
SuspensionID: SuspensionIDColumn,
AccountID: AccountIDColumn,
BlockedAt: BlockedAtColumn,
BlockedUntil: BlockedUntilColumn,
ReasonEn: ReasonEnColumn,
ReasonRu: ReasonRuColumn,
ReasonID: ReasonIDColumn,
LiftedAt: LiftedAtColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
DefaultColumns: defaultColumns,
}
}
@@ -0,0 +1,90 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var SuspensionReasons = newSuspensionReasonsTable("backend", "suspension_reasons", "")
type suspensionReasonsTable struct {
postgres.Table
// Columns
ReasonID postgres.ColumnString
TextEn postgres.ColumnString
TextRu postgres.ColumnString
CreatedAt postgres.ColumnTimestampz
UpdatedAt postgres.ColumnTimestampz
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
DefaultColumns postgres.ColumnList
}
type SuspensionReasonsTable struct {
suspensionReasonsTable
EXCLUDED suspensionReasonsTable
}
// AS creates new SuspensionReasonsTable with assigned alias
func (a SuspensionReasonsTable) AS(alias string) *SuspensionReasonsTable {
return newSuspensionReasonsTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new SuspensionReasonsTable with assigned schema name
func (a SuspensionReasonsTable) FromSchema(schemaName string) *SuspensionReasonsTable {
return newSuspensionReasonsTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new SuspensionReasonsTable with assigned table prefix
func (a SuspensionReasonsTable) WithPrefix(prefix string) *SuspensionReasonsTable {
return newSuspensionReasonsTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new SuspensionReasonsTable with assigned table suffix
func (a SuspensionReasonsTable) WithSuffix(suffix string) *SuspensionReasonsTable {
return newSuspensionReasonsTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newSuspensionReasonsTable(schemaName, tableName, alias string) *SuspensionReasonsTable {
return &SuspensionReasonsTable{
suspensionReasonsTable: newSuspensionReasonsTableImpl(schemaName, tableName, alias),
EXCLUDED: newSuspensionReasonsTableImpl("", "excluded", ""),
}
}
func newSuspensionReasonsTableImpl(schemaName, tableName, alias string) suspensionReasonsTable {
var (
ReasonIDColumn = postgres.StringColumn("reason_id")
TextEnColumn = postgres.StringColumn("text_en")
TextRuColumn = postgres.StringColumn("text_ru")
CreatedAtColumn = postgres.TimestampzColumn("created_at")
UpdatedAtColumn = postgres.TimestampzColumn("updated_at")
allColumns = postgres.ColumnList{ReasonIDColumn, TextEnColumn, TextRuColumn, CreatedAtColumn, UpdatedAtColumn}
mutableColumns = postgres.ColumnList{TextEnColumn, TextRuColumn, CreatedAtColumn, UpdatedAtColumn}
defaultColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn}
)
return suspensionReasonsTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ReasonID: ReasonIDColumn,
TextEn: TextEnColumn,
TextRu: TextRuColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
DefaultColumns: defaultColumns,
}
}
@@ -11,6 +11,7 @@ package table
// this method only once at the beginning of the program.
func UseSchema(schema string) {
AccountStats = AccountStats.FromSchema(schema)
AccountSuspensions = AccountSuspensions.FromSchema(schema)
Accounts = Accounts.FromSchema(schema)
Blocks = Blocks.FromSchema(schema)
ChatMessages = ChatMessages.FromSchema(schema)
@@ -28,4 +29,5 @@ func UseSchema(schema string) {
Games = Games.FromSchema(schema)
Identities = Identities.FromSchema(schema)
Sessions = Sessions.FromSchema(schema)
SuspensionReasons = SuspensionReasons.FromSchema(schema)
}