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

Fix duplicate GDers in mapfeed embed and support multiple diff owners #41

Merged
merged 2 commits into from
Dec 13, 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: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
**/obj/
**/bin/
**/*.json
**/*.user
**/*.DotSettings
13 changes: 7 additions & 6 deletions src/Numerous.Bot/Osu/MapFeedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ private async Task CheckForNewBeatmapsetsAsync(CancellationToken ct)
var fullSet = await api.GetBeatmapsetAsync(set.Id);

var gdMapperIds = fullSet.Beatmaps
.Select(u => u.UserId)
.Where(id => id != fullSet.UserId)
.ToArray();
.SelectMany(b => b.Owners)
.Where(o => o.Id != fullSet.UserId)
.Select(o => o.Id)
.ToHashSet();

var allMapperOsuIds = gdMapperIds
.Prepend(fullSet.UserId)
.ToArray();
.Append(fullSet.UserId)
.ToHashSet();

if (allMapperOsuIds.All(id => !osuUserDiscordIdDic.ContainsKey(id)))
{
Expand All @@ -86,7 +87,7 @@ private async Task CheckForNewBeatmapsetsAsync(CancellationToken ct)
var allMapperDiscordIds = allMapperOsuIds
.Where(osuUserDiscordIdDic.ContainsKey)
.Select(osuId => osuUserDiscordIdDic[osuId])
.ToArray();
.ToHashSet();

var mapper = osuUserDiscordIdDic.TryGetValue(fullSet.UserId, out var userId)
? $"{MentionUtils.MentionUser(userId)} ({Link.OsuUser(fullSet.UserId, fullSet.Creator)})"
Expand Down
13 changes: 13 additions & 0 deletions src/Numerous.Bot/Web/Osu/Models/ApiBeatmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ public record ApiBeatmap

[JsonProperty("difficulty_rating")]
public required float DifficultyRating { get; init; }

[JsonProperty("owners")]
public required IReadOnlyCollection<Owner> Owners { get; init; }

[JsonObject(MemberSerialization.OptIn)]
public record Owner
{
[JsonProperty("id")]
public required uint Id { get; init; }

[JsonProperty("username")]
public required string Username { get; init; }
}
}

public sealed record ApiBeatmapExtended : ApiBeatmap
Expand Down
Loading