Skip to content

Commit

Permalink
Merge branch 'NeverEndingTrainOfFixes' into OpenDream
Browse files Browse the repository at this point in the history
Also fixes logic error in `AdvancedWatchdog.HandleNewDmbAvailable` in the `EngineType.OpenDream` case.
  • Loading branch information
Cyberboss committed Nov 19, 2023
2 parents 2432c22 + f4a4e08 commit 6967d9f
Show file tree
Hide file tree
Showing 14 changed files with 425 additions and 361 deletions.
319 changes: 159 additions & 160 deletions src/Tgstation.Server.Host/Components/Chat/ChatManager.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public interface IChatTrackingContext : IChannelSink, IDisposable
/// <summary>
/// If the <see cref="CustomCommands"/> should be used.
/// </summary>
/// <remarks>This should only be set by the <see cref="object"/> that sets the <see cref="CustomCommands"/>.</remarks>
bool Active { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
Expand Down Expand Up @@ -659,6 +660,7 @@ protected override async ValueTask DisconnectImpl(CancellationToken cancellation

var remapRequired = false;
var guildsClient = serviceProvider.GetRequiredService<IDiscordRestGuildAPI>();
var guildTasks = new ConcurrentDictionary<Snowflake, Task<Result<IGuild>>>();

async ValueTask<Tuple<Models.ChatChannel, IEnumerable<ChannelRepresentation>>> GetModelChannelFromDBChannel(Models.ChatChannel channelFromDB)
{
Expand Down Expand Up @@ -690,17 +692,28 @@ protected override async ValueTask DisconnectImpl(CancellationToken cancellation

var guildId = discordChannelResponse.Entity.GuildID.Value;

var guildsResponse = await guildsClient.GetGuildAsync(
var added = false;
var guildsResponse = await guildTasks.GetOrAdd(
guildId,
false,
cancellationToken);
localGuildId =>
{
added = true;
return guildsClient.GetGuildAsync(
localGuildId,
false,
cancellationToken);
});
if (!guildsResponse.IsSuccess)
{
Logger.LogWarning(
"Error retrieving discord guild {guildID}: {result}",
guildId,
guildsResponse.LogFormat());
remapRequired |= true;
if (added)
{
Logger.LogWarning(
"Error retrieving discord guild {guildID}: {result}",
guildId,
guildsResponse.LogFormat());
remapRequired |= true;
}

return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@ interface ISessionController : IProcessBase, IRenameNotifyee, IAsyncDisposable
/// </summary>
void ResetRebootState();

/// <summary>
/// Enables the reading of custom chat commands from the <see cref="ISessionController"/>.
/// </summary>
void EnableCustomChatCommands();

/// <summary>
/// Replace the <see cref="IDmbProvider"/> in use with a given <paramref name="newProvider"/>, disposing the old one.
/// </summary>
Expand Down
Loading

0 comments on commit 6967d9f

Please sign in to comment.