1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-08 18:44:04 +08:00

Adjust behavior of beatmap set with deleted author

This commit is contained in:
eyhn
2025-07-14 20:55:44 +08:00
Unverified
parent 64f6fce918
commit 3eca3897ed
2 changed files with 55 additions and 4 deletions
@@ -10,6 +10,8 @@ using osu.Game.Rulesets;
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using osu.Framework.Testing;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics.Sprites;
@@ -193,7 +195,8 @@ namespace osu.Game.Tests.Visual.Online
overlay.ShowBeatmapSet(set);
});
AddAssert("shown beatmaps of current ruleset", () => overlay.Header.HeaderContent.Picker.Difficulties.All(b => b.Beatmap.Ruleset.OnlineID == overlay.Header.RulesetSelector.Current.Value.OnlineID));
AddAssert("shown beatmaps of current ruleset",
() => overlay.Header.HeaderContent.Picker.Difficulties.All(b => b.Beatmap.Ruleset.OnlineID == overlay.Header.RulesetSelector.Current.Value.OnlineID));
AddAssert("left-most beatmap selected", () => overlay.Header.HeaderContent.Picker.Difficulties.First().State == BeatmapPicker.DifficultySelectorState.Selected);
}
@@ -373,6 +376,39 @@ namespace osu.Game.Tests.Visual.Online
});
}
[Test]
public void TestBeatmapsetWithDeletedUser()
{
AddStep("show map with deleted user", () =>
{
JObject jsonBlob = JObject.FromObject(getBeatmapSet(), new JsonSerializer
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
jsonBlob["user"] = JToken.Parse(
"""
{
"avatar_url": null,
"country_code": null,
"default_group": "default",
"id": null,
"is_active": false,
"is_bot": false,
"is_deleted": true,
"is_online": false,
"is_supporter": false,
"last_visit": null,
"pm_friends_only": false,
"profile_colour": null,
"username": "[deleted user]"
}
""");
overlay.ShowBeatmapSet(JsonConvert.DeserializeObject<APIBeatmapSet>(JsonConvert.SerializeObject(jsonBlob)));
});
}
private APIBeatmapSet createManyDifficultiesBeatmapSet()
{
var set = getBeatmapSet();
@@ -84,11 +84,26 @@ namespace osu.Game.Online.API.Requests.Responses
/// The creator of this beatmap set.
/// </summary>
/// <remarks>
/// This is not included when the set is retrieved via <see cref="SearchBeatmapSetsRequest"/>,
/// but the creator's ID and username will be filled in this property from the <see cref="AuthorID"/> and <see cref="AuthorString"/> properties.
/// This property is set differently depending on the API endpoint. When retrieved via <see cref="SearchBeatmapSetsRequest"/>,
/// detailed user info is not included and the creator's ID and username are filled from the <see cref="AuthorID"/> and
/// <see cref="AuthorString"/> properties. For other API endpoints, this property is set by the <see cref="author"/> setter.
/// </remarks>
public APIUser Author = new APIUser();
/// <summary>
/// Helper property to deserialize the detailed user info to <see cref="Author"/>
/// </summary>
/// <remarks>
/// This setter implements special handling for deleted users. When received a user with ID 1, it indicates
/// the original user has been deleted. In such cases, the existing <see cref="Author"/> data
/// (filled from <see cref="AuthorID"/> and <see cref="AuthorString"/>) is preserved. For valid user,
/// the provided user info replaces the existing <see cref="Author"/>.
/// </remarks>
[JsonProperty(@"user")]
public APIUser Author = new APIUser();
private APIUser author
{
set => Author = value.Id != 1 ? value : Author;
}
/// <summary>
/// The ID of the beatmap set's creator.