From 05b30c0c7ac093ce0b5e11a61a18b14ba24d5c94 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Thu, 16 Jan 2025 20:13:33 +0900 Subject: [PATCH] Fix connection errors on self-friends --- osu.Server.Spectator/Hubs/Metadata/MetadataHub.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Server.Spectator/Hubs/Metadata/MetadataHub.cs b/osu.Server.Spectator/Hubs/Metadata/MetadataHub.cs index 9a3e12c2..ba5814e7 100644 --- a/osu.Server.Spectator/Hubs/Metadata/MetadataHub.cs +++ b/osu.Server.Spectator/Hubs/Metadata/MetadataHub.cs @@ -75,6 +75,11 @@ public override async Task OnConnectedAsync() { foreach (int friendId in await db.GetUserFriendsAsync(usage.Item.UserId)) { + // Once upon a time users were able to add themselves as friends. + // This errors during the state retrieval below, so let's not support it. + if (friendId == usage.Item.UserId) + continue; + await Groups.AddToGroupAsync(Context.ConnectionId, FRIEND_PRESENCE_WATCHERS_GROUP(friendId)); // Check if the friend is online, and if they are, broadcast to the connected user.