feat(social): hide social controls on a deleted opponent's seat
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 29s
CI / integration (pull_request) Successful in 20s
CI / ui (pull_request) Successful in 1m17s
CI / conformance (pull_request) Successful in 11s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m49s
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 29s
CI / integration (pull_request) Successful in 20s
CI / ui (pull_request) Successful in 1m17s
CI / conformance (pull_request) Successful in 11s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m49s
A deleted account keeps its seats in every shared game, so its opponents
still saw the add-friend and block controls on the scoreboard (deletion
drops the friendship, so the 🤝 even reappeared for a former friend) and
a chat composer nobody was behind. A friend request sent that way was
accepted by the server and stayed pending forever.
The per-viewer game views now mark such a seat (SeatView.deleted,
resolved beside the seat display names by a batch accounts.deleted_at
lookup) and the client hides every control aimed at it: add-friend,
block, and the chat composer (message + nudge) once no reachable
opponent is left. Live events carry the game domain's seat standings and
so leave the mark unset, so the delta reducers preserve the cached one.
SendFriendRequest and Block against a tombstone are refused with
social.ErrAccountDeleted (410 account_deleted) — the source of truth for
an older client.
This commit is contained in:
@@ -153,7 +153,8 @@ type MoveRecordResp struct {
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
// SeatResp is one seat's public standing.
|
||||
// SeatResp is one seat's public standing. Deleted marks a seat whose account has been
|
||||
// deleted, so the client can hide the social controls aimed at it.
|
||||
type SeatResp struct {
|
||||
Seat int `json:"seat"`
|
||||
AccountID string `json:"account_id"`
|
||||
@@ -161,6 +162,7 @@ type SeatResp struct {
|
||||
Score int `json:"score"`
|
||||
HintsUsed int `json:"hints_used"`
|
||||
IsWinner bool `json:"is_winner"`
|
||||
Deleted bool `json:"deleted"`
|
||||
}
|
||||
|
||||
// GameResp is the shared game summary.
|
||||
|
||||
@@ -618,6 +618,7 @@ func toWireGame(g backendclient.GameResp) wire.GameView {
|
||||
HintsUsed: s.HintsUsed,
|
||||
IsWinner: s.IsWinner,
|
||||
DisplayName: s.DisplayName,
|
||||
Deleted: s.Deleted,
|
||||
}
|
||||
}
|
||||
return wire.GameView{
|
||||
|
||||
@@ -300,7 +300,7 @@ func TestGamesListRoundTripDecodesSeatNames(t *testing.T) {
|
||||
if r.URL.Path != "/api/v1/user/games" {
|
||||
t.Errorf("unexpected path %q", r.URL.Path)
|
||||
}
|
||||
_, _ = w.Write([]byte(`{"games":[{"id":"g-1","variant":"scrabble_en","status":"active","players":2,"to_move":0,"last_activity_unix":1717000000,"unread_chat":true,"unread_messages":true,"seats":[{"seat":0,"account_id":"u-9","display_name":"You","score":10},{"seat":1,"account_id":"a-1","display_name":"Ann","score":7}]}],"at_game_limit":true}`))
|
||||
_, _ = w.Write([]byte(`{"games":[{"id":"g-1","variant":"scrabble_en","status":"active","players":2,"to_move":0,"last_activity_unix":1717000000,"unread_chat":true,"unread_messages":true,"seats":[{"seat":0,"account_id":"u-9","display_name":"You","score":10},{"seat":1,"account_id":"a-1","display_name":"Ann","score":7,"deleted":true}]}],"at_game_limit":true}`))
|
||||
})
|
||||
defer cleanup()
|
||||
|
||||
@@ -333,6 +333,14 @@ func TestGamesListRoundTripDecodesSeatNames(t *testing.T) {
|
||||
if string(seat.DisplayName()) != "Ann" {
|
||||
t.Errorf("seat display name = %q, want Ann", seat.DisplayName())
|
||||
}
|
||||
if !seat.Deleted() {
|
||||
t.Error("seat deleted = false, want true (the backend marked the seat's account deleted)")
|
||||
}
|
||||
var own fb.SeatView
|
||||
g.Seats(&own, 0)
|
||||
if own.Deleted() {
|
||||
t.Error("seat deleted = true for a live account, want false")
|
||||
}
|
||||
if !gl.AtGameLimit() {
|
||||
t.Error("at_game_limit = false, want true (the backend reported the cap)")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user