feat(social): asymmetric per-user block, in-game block control, admin lists
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 15s
CI / ui (pull_request) Successful in 51s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m19s

Make a per-user block one-directional and non-destructive: the blocker stops
receiving everything from the blocked user (chat, nudge, friend requests,
invitations) and the matchmaker never pairs them, while the blocked user
notices nothing — their sends still persist by the normal rules but are never
delivered or surfaced (born-read). A block no longer deletes the friendship
(an unblock cleanly restores it) and instant-reads any unread the blocked user
had left for the blocker.

- backend: a directional blockExists guard across chat/nudge/friends/invitations
  (store-but-hide for the blocked->blocker direction, refuse blocker->blocked);
  the matchmaker excludes a block-related pair (both directions) from auto-match;
  user_blocked/user_unblocked notifications to the blocker only (in-app only).
- ui: the opponent score card gains a block ✖️ control mirroring add-friend
  (red "Block?" confirm, mutual-hide while confirming, struck name, hidden chat
  composer when blocked); optimistic apply + event confirm + rollback for both.
- admin: the user card gains cross-linked blocks / blocked-by / friends lists.
- docs: FUNCTIONAL(+ru), ARCHITECTURE §10 + decision record, UI_DESIGN, PRERELEASE.
This commit is contained in:
Ilia Denisov
2026-06-18 11:50:34 +02:00
parent 9074417762
commit 81b9e1529e
34 changed files with 1191 additions and 109 deletions
@@ -389,9 +389,30 @@ func (s *Server) consoleUserDetail(c *gin.Context) {
view.Roles = roles
}
view.KnownRoles = account.KnownRoles
if s.social != nil {
if rels, err := s.social.AdminBlocksBy(ctx, id); err == nil {
view.Blocks = relationRows(rels)
}
if rels, err := s.social.AdminBlockedBy(ctx, id); err == nil {
view.BlockedBy = relationRows(rels)
}
if rels, err := s.social.AdminFriends(ctx, id); err == nil {
view.Friends = relationRows(rels)
}
}
s.renderConsole(c, "user_detail", "users", acc.DisplayName, view)
}
// relationRows maps the social graph entries to the cross-linked, date-formatted rows the
// user card renders.
func relationRows(rels []social.AdminRelation) []adminconsole.RelationRow {
out := make([]adminconsole.RelationRow, 0, len(rels))
for _, r := range rels {
out = append(out, adminconsole.RelationRow{AccountID: r.AccountID.String(), DisplayName: r.DisplayName, Date: fmtTime(r.At)})
}
return out
}
// consoleUserMessage sends an operator Telegram message to one user.
func (s *Server) consoleUserMessage(c *gin.Context) {
ctx := c.Request.Context()
+5 -4
View File
@@ -7,10 +7,11 @@ import (
"github.com/google/uuid"
)
// The /api/v1/user/blocks/* handlers wire the per-user block list. A block
// is mutual in effect (the social checks apply it both ways) and severs any
// friendship between the pair. They reuse the friend handlers' targetIDRequest and
// account-ref resolution.
// The /api/v1/user/blocks/* handlers wire the per-user block list. A block is asymmetric:
// the blocker stops seeing everything from the blocked user (chat, nudge, requests,
// invitations, matchmaking) while the blocked user notices nothing; it overrides — but does
// not delete — any friendship (an unblock restores it). They reuse the friend handlers'
// targetIDRequest and account-ref resolution.
// blockListDTO is the accounts the caller has blocked.
type blockListDTO struct {