mirror of
https://github.com/ppy/osu
synced 2024-12-13 02:17:32 +00:00
Update API responses for chat.
This commit is contained in:
parent
3eca32a380
commit
325af333b9
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -136,11 +136,11 @@ namespace osu.Game.Overlays
|
||||
fetchReq = new GetMessagesRequest(careChannels, lastMessageId);
|
||||
fetchReq.Success += delegate (List<Message> 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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user