Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make "failed to update lobby" a warning, and add information #111

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/signaling/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ func (p *Peer) HandleUpdatePacket(ctx context.Context, packet LobbyUpdatePacket)

err := p.store.UpdateCustomData(ctx, p.Game, p.Lobby, p.ID, packet.Public, packet.CustomData, packet.CanUpdateBy)
if err != nil {
logger.Error("failed to update lobby", zap.Error(err), zap.Any("customData", packet.CustomData))
logger.Warn("failed to update lobby", zap.Error(err), zap.Any("customData", packet.CustomData))
util.ReplyError(ctx, p.conn, fmt.Errorf("unable to update lobby: %v", err))
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions internal/signaling/stores/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,14 +634,14 @@ func (s *PostgresStore) UpdateCustomData(ctx context.Context, game, lobby, peer
// No restrictions.
case CanUpdateByCreator:
if creator != peer {
return ErrNotAllowed
return errors.New("not allowed: peer is not the creator")
}
case CanUpdateByLeader:
if leader != peer {
return ErrNotAllowed
return errors.New("not allowed: peer is not the leader")
}
default:
return ErrNotAllowed
return fmt.Errorf("invalid can_update_by value: %q", currentCanUpdateBy)
}

columns := make([]string, 0, 3)
Expand Down
1 change: 0 additions & 1 deletion internal/signaling/stores/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ var ErrNotFound = errors.New("lobby not found")
var ErrNoSuchTopic = errors.New("no such topic")
var ErrInvalidLobbyCode = errors.New("invalid lobby code")
var ErrInvalidPeerID = errors.New("invalid peer id")
var ErrNotAllowed = errors.New("not allowed")

type SubscriptionCallback func(context.Context, []byte)

Expand Down