mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-24 05:27:30 +01:00
Merge branch 'pr-2223' into Omega
This commit is contained in:
@@ -351,28 +351,11 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
|
||||
/// <inheritdoc />
|
||||
public void QueueWatchdogMessage(string message)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(message);
|
||||
=> QueueMessageGeneric(mapping => mapping.IsWatchdogChannel, message, "WD");
|
||||
|
||||
message = String.Format(CultureInfo.InvariantCulture, "WD: {0}", message);
|
||||
|
||||
if (!initialProviderConnectionsTask!.IsCompleted)
|
||||
logger.LogTrace("Waiting for initial provider connections before sending watchdog message...");
|
||||
|
||||
// Reimplementing QueueMessage
|
||||
QueueMessageInternal(
|
||||
new MessageContent
|
||||
{
|
||||
Text = message,
|
||||
},
|
||||
() =>
|
||||
{
|
||||
// so it doesn't change while we're using it
|
||||
lock (mappedChannels)
|
||||
return mappedChannels.Where(x => x.Value.IsWatchdogChannel).Select(x => x.Key).ToList();
|
||||
},
|
||||
true);
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public void QueueRawDeploymentMessage(string message)
|
||||
=> QueueMessageGeneric(mapping => mapping.IsUpdatesChannel, message, null);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Func<string?, string, Action<bool>> QueueDeploymentMessage(
|
||||
@@ -1111,5 +1094,38 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
|
||||
AddMessageTask(SendMessageTask());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Queues a message to a selected set of <see cref="ChannelMapping"/>s.
|
||||
/// </summary>
|
||||
/// <param name="channelSelector">A <see cref="Predicate{T}"/> for selecting the <see cref="ChannelMapping"/>s to send to.</param>
|
||||
/// <param name="message">The message to send.</param>
|
||||
/// <param name="prefix">The optional prefix to the message to be sent.</param>
|
||||
void QueueMessageGeneric(Predicate<ChannelMapping> channelSelector, string message, string? prefix)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(message);
|
||||
|
||||
if (prefix != null)
|
||||
{
|
||||
message = $"{prefix}: {message}";
|
||||
}
|
||||
|
||||
if (!initialProviderConnectionsTask!.IsCompleted)
|
||||
logger.LogTrace("Waiting for initial provider connections before sending chat message...");
|
||||
|
||||
// Reimplementing QueueMessage
|
||||
QueueMessageInternal(
|
||||
new MessageContent
|
||||
{
|
||||
Text = message,
|
||||
},
|
||||
() =>
|
||||
{
|
||||
// so it doesn't change while we're using it
|
||||
lock (mappedChannels)
|
||||
return mappedChannels.Where(x => channelSelector(x.Value)).Select(x => x.Key).ToList();
|
||||
},
|
||||
true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,12 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
/// <param name="message">The message being sent.</param>
|
||||
void QueueWatchdogMessage(string message);
|
||||
|
||||
/// <summary>
|
||||
/// Queue a chat <paramref name="message"/> to configured deployment channels.
|
||||
/// </summary>
|
||||
/// <param name="message">The message being sent.</param>
|
||||
void QueueRawDeploymentMessage(string message);
|
||||
|
||||
/// <summary>
|
||||
/// Send the message for a deployment to configured deployment channels.
|
||||
/// </summary>
|
||||
|
||||
@@ -531,7 +531,10 @@ namespace Tgstation.Server.Host.Components
|
||||
}
|
||||
}
|
||||
else if (preserveTestMerges)
|
||||
{
|
||||
Chat.QueueRawDeploymentMessage("Automatic update has failed due to a conflicting testmerge!");
|
||||
throw new JobException(Api.Models.ErrorCode.InstanceUpdateTestMergeConflict);
|
||||
}
|
||||
|
||||
if (!preserveTestMerges)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user