diff --git a/osu.Game/Online/Chat/Message.cs b/osu.Game/Online/Chat/Message.cs index b267cf63ac..5d781459e8 100644 --- a/osu.Game/Online/Chat/Message.cs +++ b/osu.Game/Online/Chat/Message.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.ComponentModel; using Newtonsoft.Json; using osu.Game.Users; @@ -16,8 +17,11 @@ namespace osu.Game.Online.Chat [JsonProperty(@"user_id")] public int UserId; - [JsonProperty(@"channel_id")] - public int ChannelId; + [JsonProperty(@"target_type")] + public TargetType TargetType; + + [JsonProperty(@"target_id")] + public int TargetId; [JsonProperty(@"timestamp")] public DateTimeOffset Timestamp; @@ -33,4 +37,12 @@ namespace osu.Game.Online.Chat { } } + + public enum TargetType + { + [Description(@"channel")] + Channel, + [Description(@"user")] + User + } } diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index fc12789b05..db0d89edc7 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -136,11 +136,11 @@ namespace osu.Game.Overlays fetchReq = new GetMessagesRequest(careChannels, lastMessageId); fetchReq.Success += delegate (List messages) { - var ids = messages.Select(m => m.ChannelId).Distinct(); - + var ids = messages.Where(m => m.TargetType == TargetType.Channel).Select(m => m.TargetId).Distinct(); + //batch messages per channel. foreach (var id in ids) - careChannels.Find(c => c.Id == id)?.AddNewMessages(messages.Where(m => m.ChannelId == id)); + careChannels.Find(c => c.Id == id)?.AddNewMessages(messages.Where(m => m.TargetId == id)); lastMessageId = messages.LastOrDefault()?.Id ?? lastMessageId;