Update chat tracking contexts after reattaching

Fixes #1490
This commit is contained in:
Dominion
2023-05-20 19:15:31 -04:00
parent 90593f4fb2
commit 5967c178d4
3 changed files with 23 additions and 9 deletions
@@ -232,7 +232,6 @@ namespace Tgstation.Server.Host.Components.Chat
channelIdCounter += (ulong)results.Count;
}
Task trackingContextUpdateTask;
lock (mappedChannels)
{
lock (providers)
@@ -245,16 +244,9 @@ namespace Tgstation.Server.Host.Components.Chat
mappedChannels.Add(newId, newMapping);
newMapping.Channel.RealId = newId;
}
lock (trackingContexts)
trackingContextUpdateTask = Task.WhenAll(
trackingContexts.Select(
x => x.UpdateChannels(
mappedChannels.Select(y => y.Value.Channel).ToList(),
cancellationToken)));
}
await trackingContextUpdateTask;
await UpdateTrackingContexts(cancellationToken);
}
finally
{
@@ -472,6 +464,18 @@ namespace Tgstation.Server.Host.Components.Chat
return context;
}
/// <inheritdoc />
public Task UpdateTrackingContexts(CancellationToken cancellationToken)
{
lock (mappedChannels)
lock (trackingContexts)
return Task.WhenAll(
trackingContexts.Select(
x => x.UpdateChannels(
mappedChannels.Select(y => y.Value.Channel).ToList(),
cancellationToken)));
}
/// <inheritdoc />
public void RegisterCommandHandler(ICustomCommandHandler customCommandHandler)
{
@@ -84,5 +84,12 @@ namespace Tgstation.Server.Host.Components.Chat
/// </summary>
/// <returns>A new <see cref="IChatTrackingContext"/>.</returns>
IChatTrackingContext CreateTrackingContext();
/// <summary>
/// Force an update with the active channels on all active <see cref="IChatTrackingContext"/>s.
/// </summary>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
/// <returns>A <see cref="Task"/> representing the running operation.</returns>
Task UpdateTrackingContexts(CancellationToken cancellationToken);
}
}
@@ -384,8 +384,11 @@ namespace Tgstation.Server.Host.Components.Watchdog
{
if (core.Watchdog != this)
throw new InvalidOperationException(Instance.DifferentCoreExceptionMessage);
using (await SemaphoreSlimContext.Lock(synchronizationSemaphore, ct))
await LaunchNoLock(true, true, true, reattachInfo, ct);
await Chat.UpdateTrackingContexts(ct);
},
cancellationToken)
;