owpengram-server/internal/domain/admin.go
Astra f33e25af8d admin: add account spam restriction (join/message gate)
Adds a narrower spam sanction alongside the existing account freeze: a
restricted account keeps every existing membership and conversation, but
cannot join new channels/groups (public join or invite link) and cannot
start a new conversation with a non-contact. Reachable both as a standalone
admin action and as a decision on a reported user's moderation case, with
the same idempotent-supersession and appeal wiring freeze already has.
2026-09-16 14:03:15 +01:00

73 lines
2 KiB
Go

package domain
import "time"
type AdminCommandStatus string
const (
AdminCommandRunning AdminCommandStatus = "running"
AdminCommandCompleted AdminCommandStatus = "completed"
AdminCommandFailed AdminCommandStatus = "failed"
)
type AdminCommand struct {
CommandID string
Actor string
Action string
TargetUserID int64
TargetPeer Peer
DryRun bool
Reason string
RequestJSON []byte
ResultJSON []byte
Status AdminCommandStatus
Error string
CreatedAt time.Time
CompletedAt *time.Time
}
// AccountFreeze is the durable account-level read-only state advertised to
// Telegram clients through help.getAppConfig. Until is the appeal/deletion
// deadline; reaching it does not silently unfreeze the account.
type AccountFreeze struct {
UserID int64
Frozen bool
Version int64
Since time.Time
Until time.Time
AppealURL string
Reason string
Actor string
CommandID string
UpdatedAt time.Time
}
// AccountFreezeNotification is a durable, coalesced online refresh for one
// viewer. UpdateUser itself has no pts; offline clients always recover from the
// authoritative viewer-scoped user projection instead of replaying this row.
type AccountFreezeNotification struct {
ID int64
TargetUserID int64
FrozenUserID int64
Version int64
Frozen bool
Attempts int
}
// AccountRestriction is the durable, narrower spam sanction: unlike
// AccountFreeze it does not make the account read-only. A restricted account
// keeps every existing membership and conversation; it can only not join new
// channels/groups and not start new conversations with non-contacts. Until,
// when set, is when the restriction auto-lifts; a zero Until means it stays
// in effect until an admin clears it.
type AccountRestriction struct {
UserID int64
Restricted bool
Version int64
Since time.Time
Until time.Time
Reason string
Actor string
CommandID string
UpdatedAt time.Time
}