Fix last silence ID being updated too often, causing most silences to be missed

This commit is contained in:
Dean Herbert 2022-11-12 23:32:05 +09:00
parent 143c946128
commit 22d8a1160e
2 changed files with 6 additions and 5 deletions

View File

@ -9,14 +9,15 @@ namespace osu.Game.Online.API.Requests
{
public class ChatAckRequest : APIRequest<ChatAckResponse>
{
public long SinceMessageId;
public long? SinceMessageId;
public uint? SinceSilenceId;
protected override WebRequest CreateWebRequest()
{
var req = base.CreateWebRequest();
req.Method = HttpMethod.Post;
req.AddParameter(@"since", SinceMessageId.ToString());
if (SinceMessageId != null)
req.AddParameter(@"since", SinceMessageId.ToString());
if (SinceSilenceId != null)
req.AddParameter(@"history_since", SinceSilenceId.Value.ToString());
return req;

View File

@ -74,7 +74,7 @@ namespace osu.Game.Online.Chat
private bool channelsInitialised;
private ScheduledDelegate scheduledAck;
private long lastMessageId;
private long? lastSilenceMessageId;
private uint? lastSilenceId;
public ChannelManager(IAPIProvider api)
@ -332,7 +332,7 @@ namespace osu.Game.Online.Chat
foreach (var group in messages.GroupBy(m => m.ChannelId))
channels.Find(c => c.Id == group.Key)?.AddNewMessages(group.ToArray());
lastMessageId = messages.LastOrDefault()?.Id ?? lastMessageId;
lastSilenceMessageId ??= messages.LastOrDefault()?.Id;
}
private void initializeChannels()
@ -394,7 +394,7 @@ namespace osu.Game.Online.Chat
var req = new ChatAckRequest
{
SinceMessageId = lastMessageId,
SinceMessageId = lastSilenceMessageId,
SinceSilenceId = lastSilenceId
};