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
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:
@@ -150,6 +150,14 @@ func (svc *InvitationService) emitInvitationUpdate(ctx context.Context, inv Invi
|
||||
}
|
||||
intents := make([]notify.Intent, 0, len(recipients))
|
||||
for _, id := range recipients {
|
||||
// An invitee who has blocked the inviter never sees this invitation, so they must not
|
||||
// receive its updates either (an update would otherwise re-add it to their lobby). The
|
||||
// inviter always gets updates; on a lookup error suppress rather than risk a leak.
|
||||
if id != inv.InviterID {
|
||||
if blk, err := svc.blocker.Blocks(ctx, id, inv.InviterID); err != nil || blk {
|
||||
continue
|
||||
}
|
||||
}
|
||||
intents = append(intents, notify.NotificationInvitationUpdate(id, summary))
|
||||
}
|
||||
svc.pub.Publish(intents...)
|
||||
@@ -211,6 +219,11 @@ func (svc *InvitationService) CreateInvitation(ctx context.Context, inviterID uu
|
||||
return Invitation{}, fmt.Errorf("%w: turn timeout %s not allowed", ErrInvalidInvitation, settings.TurnTimeout)
|
||||
}
|
||||
seen := map[uuid.UUID]bool{inviterID: true}
|
||||
// suppressed collects invitees who have blocked the inviter: the invitation is still
|
||||
// created and persisted for them, but they are never notified and never see it (their
|
||||
// friendship with the inviter survived the block, so they can still appear in the
|
||||
// inviter's picker — they must not learn of the block).
|
||||
suppressed := make(map[uuid.UUID]bool)
|
||||
for _, id := range inviteeIDs {
|
||||
if seen[id] {
|
||||
return Invitation{}, fmt.Errorf("%w: %s invited twice or is the inviter", ErrInvalidInvitation, id)
|
||||
@@ -222,13 +235,22 @@ func (svc *InvitationService) CreateInvitation(ctx context.Context, inviterID uu
|
||||
}
|
||||
return Invitation{}, err
|
||||
}
|
||||
blocked, err := svc.blocker.IsBlocked(ctx, inviterID, id)
|
||||
// A block the inviter placed refuses the invite (the inviter is aware; the picker hides
|
||||
// the invitee anyway). A block the invitee placed on the inviter is instead suppressed.
|
||||
iBlock, err := svc.blocker.Blocks(ctx, inviterID, id)
|
||||
if err != nil {
|
||||
return Invitation{}, err
|
||||
}
|
||||
if blocked {
|
||||
if iBlock {
|
||||
return Invitation{}, ErrInvitationBlocked
|
||||
}
|
||||
theyBlock, err := svc.blocker.Blocks(ctx, id, inviterID)
|
||||
if err != nil {
|
||||
return Invitation{}, err
|
||||
}
|
||||
if theyBlock {
|
||||
suppressed[id] = true
|
||||
}
|
||||
}
|
||||
|
||||
id, err := uuid.NewV7()
|
||||
@@ -253,7 +275,18 @@ func (svc *InvitationService) CreateInvitation(ctx context.Context, inviterID uu
|
||||
if err != nil {
|
||||
return Invitation{}, err
|
||||
}
|
||||
svc.emitInvitation(ctx, inv, inviteeIDs)
|
||||
// Notify every invitee except those who have blocked the inviter (their copy stays
|
||||
// stored but unseen — the store-but-hide that keeps the block invisible).
|
||||
notifyIDs := inviteeIDs
|
||||
if len(suppressed) > 0 {
|
||||
notifyIDs = make([]uuid.UUID, 0, len(inviteeIDs))
|
||||
for _, id := range inviteeIDs {
|
||||
if !suppressed[id] {
|
||||
notifyIDs = append(notifyIDs, id)
|
||||
}
|
||||
}
|
||||
}
|
||||
svc.emitInvitation(ctx, inv, notifyIDs)
|
||||
return inv, nil
|
||||
}
|
||||
|
||||
@@ -347,6 +380,17 @@ func (svc *InvitationService) ListInvitations(ctx context.Context, accountID uui
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Hide an invitation whose inviter the viewer has blocked: it stays stored but must
|
||||
// never surface to the blocker. The viewer's own invitations (as inviter) are unaffected.
|
||||
if inv.InviterID != accountID {
|
||||
blocked, err := svc.blocker.Blocks(ctx, accountID, inv.InviterID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if blocked {
|
||||
continue
|
||||
}
|
||||
}
|
||||
out = append(out, inv)
|
||||
}
|
||||
return out, nil
|
||||
|
||||
Reference in New Issue
Block a user