1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 10:07:36 +08:00

Update API responses for chat.

This commit is contained in:
Dean Herbert 2017-04-19 17:39:57 +09:00
parent 3eca32a380
commit 325af333b9
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
2 changed files with 17 additions and 5 deletions

View File

@ -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
}
}

View File

@ -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;