diff --git a/src/DMAPI/tgs/v5/_defines.dm b/src/DMAPI/tgs/v5/_defines.dm index 627211cd46..1147817406 100644 --- a/src/DMAPI/tgs/v5/_defines.dm +++ b/src/DMAPI/tgs/v5/_defines.dm @@ -8,6 +8,8 @@ #define DMAPI5_BRIDGE_COMMAND_KILL 4 #define DMAPI5_BRIDGE_COMMAND_CHAT_SEND 5 +#define DMAPI5_PARAMETER_ACCESS_IDENTIFIER "accessIdentifier" + #define DMAPI5_BRIDGE_PARAMETER_COMMAND "commandType" #define DMAPI5_BRIDGE_PARAMETER_NEW_PORT "newPort" #define DMAPI5_BRIDGE_PARAMETER_VERSION "version" @@ -37,4 +39,40 @@ #define DMAPI5_CHAT_COMMAND_NAME "name" #define DMAPI5_CHAT_COMMAND_PARAMS "params" -#defin \ No newline at end of file +#define DMAPI5_CHAT_COMMAND_USER "user" + +#define DMAPI5_EVENT_NOTIFICATION_TYPE "type" +#define DMAPI5_EVENT_NOTIFICATION_PARAMETERS "parameters" + +#define DMAPI5_TOPIC_COMMAND_CHAT_COMMAND 0 +#define DMAPI5_TOPIC_COMMAND_EVENT_NOTIFICATION 1 +#define DMAPI5_TOPIC_COMMAND_CHANGE_PORT 2 +#define DMAPI5_TOPIC_COMMAND_CHANGE_REBOOT_STATE 3 +#define DMAPI5_TOPIC_COMMAND_INSTANCE_RENAMED 4 + +#define DMAPI5_TOPIC_PARAMETER_COMMAND_TYPE "commandType" +#define DMAPI5_TOPIC_PARAMETER_CHAT_COMMAND "chatCommand" +#define DMAPI5_TOPIC_PARAMETER_EVENT_NOTIFICATION "eventNotification" +#define DMAPI5_TOPIC_PARAMETER_NEW_PORT "newPort" +#define DMAPI5_TOPIC_PARAMETER_NEW_REBOOT_STATE "newRebootState" +#define DMAPI5_TOPIC_PARAMETER_NEW_INSTANCE_NAME "newInstanceName" + +#define DMAPI5_TOPIC_RESPONSE_ERROR_MESSAGE "errorMessage" +#define DMAPI5_TOPIC_RESPONSE_COMMAND_RESPONSE_MESSAGE "commandResponseMessage" +#define DMAPI5_TOPIC_RESPONSE_CHAT_RESPONSES "chatResponses" + +#define DMAPI5_REVISION_INFORMATION_COMMIT_SHA "commitSha" +#define DMAPI5_REVISION_INFORMATION_ORIGIN_COMMIT_SHA "originCommitSha" + +#define DMAPI5_CHAT_USER_ID "id" +#define DMAPI5_CHAT_USER_FRIENDLY_NAME "friendlyName" +#define DMAPI5_CHAT_USER_MENTION "mention" +#define DMAPI5_CHAT_USER_CHANNEL "channel" + +#define DMAPI5_CHAT_CHANNEL_ID "id" +#define DMAPI5_CHAT_CHANNEL_FRIENDLY_NAME "friendlyName" +#define DMAPI5_CHAT_CHANNEL_CONNECTION_NAME "connectionName" +#define DMAPI5_CHAT_CHANNEL_IS_ADMIN_CHANNEL "isAdminChannel" +#define DMAPI5_CHAT_CHANNEL_IS_PRIVATE_CHANNEL "isPrivateChannel" +#define DMAPI5_CHAT_CHANNEL_IS_WATCHDOG_CHANNEL "isWatchdogChannel" +#define DMAPI5_CHAT_CHANNEL_TAG "tag" diff --git a/src/Tgstation.Server.Host/Components/Chat/ChannelMapping.cs b/src/Tgstation.Server.Host/Components/Chat/ChannelMapping.cs index a1d205e6d0..7423d97cfe 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChannelMapping.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChannelMapping.cs @@ -1,7 +1,7 @@ namespace Tgstation.Server.Host.Components.Chat { /// - /// Represents a mapping of a + /// Represents a mapping of a /// sealed class ChannelMapping { @@ -11,7 +11,7 @@ public long ProviderId { get; set; } /// - /// The original + /// The original /// public ulong ProviderChannelId { get; set; } @@ -26,8 +26,8 @@ public bool IsUpdatesChannel { get; set; } /// - /// The with the mapped Id + /// The with the mapped Id /// - public Channel Channel { get; set; } + public ChatChannel Channel { get; set; } } } diff --git a/src/Tgstation.Server.Host/Components/Chat/Chat.cs b/src/Tgstation.Server.Host/Components/Chat/Chat.cs index e82a07da8c..c78be6977e 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Chat.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Chat.cs @@ -67,7 +67,7 @@ namespace Tgstation.Server.Host.Components.Chat readonly Dictionary providers; /// - /// Map of s to s + /// Map of s to s /// readonly Dictionary mappedChannels; @@ -107,7 +107,7 @@ namespace Tgstation.Server.Host.Components.Chat TaskCompletionSource connectionsUpdated; /// - /// Used for remapping s + /// Used for remapping s /// ulong channelIdCounter; diff --git a/src/Tgstation.Server.Host/Components/Chat/Channel.cs b/src/Tgstation.Server.Host/Components/Chat/ChatChannel.cs similarity index 88% rename from src/Tgstation.Server.Host/Components/Chat/Channel.cs rename to src/Tgstation.Server.Host/Components/Chat/ChatChannel.cs index fe5d6acb15..e714979593 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Channel.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatChannel.cs @@ -7,7 +7,7 @@ namespace Tgstation.Server.Host.Components.Chat /// /// Represents a channel /// - public sealed class Channel + public sealed class ChatChannel { /// /// Backing field for . Represented as a to avoid BYOND percision loss @@ -26,12 +26,12 @@ namespace Tgstation.Server.Host.Components.Chat } /// - /// The user friendly name of the + /// The user friendly name of the /// public string FriendlyName { get; set; } /// - /// The name of the connection the belongs to + /// The name of the connection the belongs to /// public string ConnectionName { get; set; } diff --git a/src/Tgstation.Server.Host/Components/Chat/User.cs b/src/Tgstation.Server.Host/Components/Chat/ChatUser.cs similarity index 85% rename from src/Tgstation.Server.Host/Components/Chat/User.cs rename to src/Tgstation.Server.Host/Components/Chat/ChatUser.cs index c3a5e2b6dc..f74f099fdd 100644 --- a/src/Tgstation.Server.Host/Components/Chat/User.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatUser.cs @@ -7,7 +7,7 @@ namespace Tgstation.Server.Host.Components.Chat /// /// Represents a tgs_chat_user datum /// - public sealed class User + public sealed class ChatUser { /// /// Backing field for . Represented as a to avoid BYOND percision loss @@ -35,8 +35,8 @@ namespace Tgstation.Server.Host.Components.Chat public string Mention { get; set; } /// - /// The the user spoke from + /// The the user spoke from /// - public Channel Channel { get; set; } + public ChatChannel Channel { get; set; } } } diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/ByondCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/ByondCommand.cs index 1787d305d7..7226c55ba6 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/ByondCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/ByondCommand.cs @@ -44,7 +44,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands } /// - public Task Invoke(string arguments, User user, CancellationToken cancellationToken) + public Task Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) { if (arguments.Split(' ').Any(x => x.ToUpperInvariant() == "--ACTIVE")) return Task.FromResult(byondManager.ActiveVersion == null ? "None!" : String.Format(CultureInfo.InvariantCulture, "{0}.{1}", byondManager.ActiveVersion.Major, byondManager.ActiveVersion.Minor)); diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/CustomCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/CustomCommand.cs index da23754a2d..0d6026a69d 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/CustomCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/CustomCommand.cs @@ -37,7 +37,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands } /// - public Task Invoke(string arguments, User user, CancellationToken cancellationToken) + public Task Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) { if (handler == null) throw new InvalidOperationException("SetHandler() has not been called!"); diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs index 4ff8799ce7..547c429c64 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs @@ -19,7 +19,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands string HelpText { get; } /// - /// If the command should only be available to s who's has set + /// If the command should only be available to s who's has set /// bool AdminOnly { get; } @@ -27,9 +27,9 @@ namespace Tgstation.Server.Host.Components.Chat.Commands /// Invoke the /// /// The text after with leading whitespace trimmed - /// The who invoked the command + /// The who invoked the command /// The for the operation /// A resulting in a to send to the invoker - Task Invoke(string arguments, User user, CancellationToken cancellationToken); + Task Invoke(string arguments, ChatUser user, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/KekCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/KekCommand.cs index 7fa541ef37..2916bf676a 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/KekCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/KekCommand.cs @@ -23,6 +23,6 @@ namespace Tgstation.Server.Host.Components.Chat.Commands public bool AdminOnly => false; /// - public Task Invoke(string arguments, User user, CancellationToken cancellationToken) => Task.FromResult(Kek); + public Task Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) => Task.FromResult(Kek); } } diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs index 989fc8026d..15e992da83 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs @@ -63,7 +63,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands /// // TODO: Decomplexify #pragma warning disable CA1506 - public async Task Invoke(string arguments, User user, CancellationToken cancellationToken) + public async Task Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) { IEnumerable results = null; if (arguments.Split(' ').Any(x => x.ToUpperInvariant() == "--REPO")) diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/RevisionCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/RevisionCommand.cs index b9316fe6ba..c775a36d3b 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/RevisionCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/RevisionCommand.cs @@ -51,7 +51,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands } /// - public async Task Invoke(string arguments, User user, CancellationToken cancellationToken) + public async Task Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) { string result; if (arguments.Split(' ').Any(x => x.ToUpperInvariant() == "--REPO")) diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/VersionCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/VersionCommand.cs index 858d4bc8c0..cfcccfdd6a 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/VersionCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/VersionCommand.cs @@ -34,6 +34,6 @@ namespace Tgstation.Server.Host.Components.Chat.Commands } /// - public Task Invoke(string arguments, User user, CancellationToken cancellationToken) => Task.FromResult(application.VersionString); + public Task Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) => Task.FromResult(application.VersionString); } } diff --git a/src/Tgstation.Server.Host/Components/Chat/ICustomCommandHandler.cs b/src/Tgstation.Server.Host/Components/Chat/ICustomCommandHandler.cs index 9f640cb633..cb3143fa2f 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ICustomCommandHandler.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ICustomCommandHandler.cs @@ -13,9 +13,9 @@ namespace Tgstation.Server.Host.Components.Chat /// /// The command name /// Everything typed after minus leading spaces - /// The sending + /// The sending /// The for the operation /// A resulting in the response text to send back - Task HandleChatCommand(string commandName, string arguments, User sender, CancellationToken cancellationToken); + Task HandleChatCommand(string commandName, string arguments, ChatUser sender, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/src/Tgstation.Server.Host/Components/Chat/IJsonTrackingContext.cs b/src/Tgstation.Server.Host/Components/Chat/IJsonTrackingContext.cs index 1a5ec65b7f..40edd6db42 100644 --- a/src/Tgstation.Server.Host/Components/Chat/IJsonTrackingContext.cs +++ b/src/Tgstation.Server.Host/Components/Chat/IJsonTrackingContext.cs @@ -26,9 +26,9 @@ namespace Tgstation.Server.Host.Components.Chat /// /// Writes information about connected to the /// - /// The s to write out + /// The s to write out /// The for the operation /// A representing the running operation - Task SetChannels(IEnumerable channels, CancellationToken cancellationToken); + Task SetChannels(IEnumerable channels, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/src/Tgstation.Server.Host/Components/Chat/JsonTrackingContext.cs b/src/Tgstation.Server.Host/Components/Chat/JsonTrackingContext.cs index 5aa1ea9201..7869f436c1 100644 --- a/src/Tgstation.Server.Host/Components/Chat/JsonTrackingContext.cs +++ b/src/Tgstation.Server.Host/Components/Chat/JsonTrackingContext.cs @@ -99,7 +99,7 @@ namespace Tgstation.Server.Host.Components.Chat } /// - public async Task SetChannels(IEnumerable channels, CancellationToken cancellationToken) + public async Task SetChannels(IEnumerable channels, CancellationToken cancellationToken) { using (await SemaphoreSlimContext.Lock(channelsSemaphore, cancellationToken).ConfigureAwait(false)) { diff --git a/src/Tgstation.Server.Host/Components/Chat/Message.cs b/src/Tgstation.Server.Host/Components/Chat/Message.cs index 3989369ce8..24e18962e4 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Message.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Message.cs @@ -11,8 +11,8 @@ public string Content { get; set; } /// - /// The who sent the + /// The who sent the /// - public User User { get; set; } + public ChatUser User { get; set; } } } \ No newline at end of file diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index 32fbaab397..835760ef44 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -101,10 +101,10 @@ namespace Tgstation.Server.Host.Components.Chat.Providers var result = new Message { Content = e.Content, - User = new User + User = new ChatUser { RealId = e.Author.Id, - Channel = new Channel + Channel = new ChatChannel { RealId = e.Channel.Id, IsPrivateChannel = pm, @@ -193,7 +193,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers } /// - public override Task> MapChannels(IEnumerable channels, CancellationToken cancellationToken) + public override Task> MapChannels(IEnumerable channels, CancellationToken cancellationToken) { if (channels == null) throw new ArgumentNullException(nameof(channels)); @@ -201,10 +201,10 @@ namespace Tgstation.Server.Host.Components.Chat.Providers if (!Connected) { Logger.LogWarning("Cannot map channels, provider disconnected!"); - return Task.FromResult>(Array.Empty()); + return Task.FromResult>(Array.Empty()); } - Channel GetModelChannelFromDBChannel(ChatChannel channelFromDB) + ChatChannel GetModelChannelFromDBChannel(Api.Models.ChatChannel channelFromDB) { if (!channelFromDB.DiscordChannelId.HasValue) throw new InvalidOperationException("ChatChannel missing DiscordChannelId!"); @@ -213,7 +213,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers var discordChannel = client.GetChannel(channelId); if (discordChannel is ITextChannel textChannel) { - var channelModel = new Channel + var channelModel = new ChatChannel { RealId = discordChannel.Id, IsAdminChannel = channelFromDB.IsAdminChannel == true, @@ -238,7 +238,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers mappedChannels.AddRange(enumerator.Select(x => x.RealId)); } - return Task.FromResult>(enumerator); + return Task.FromResult>(enumerator); } /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs index 6568542180..2288be0a33 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs @@ -25,7 +25,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// /// The for the operation /// A resulting in the next available or if the needed to reconnect. - /// Note that private messages will come in the form of s not returned in . Do not the on continuations run from the returned . + /// Note that private messages will come in the form of s not returned in . Do not the on continuations run from the returned . Task NextMessage(CancellationToken cancellationToken); /// @@ -43,17 +43,17 @@ namespace Tgstation.Server.Host.Components.Chat.Providers Task Disconnect(CancellationToken cancellationToken); /// - /// Get the s for given + /// Get the s for given /// /// The s to map /// The for the operation - /// A resulting in a of the s representing - Task> MapChannels(IEnumerable channels, CancellationToken cancellationToken); + /// A resulting in a of the s representing + Task> MapChannels(IEnumerable channels, CancellationToken cancellationToken); /// /// Send a message to the /// - /// The to send to + /// The to send to /// The message contents /// The for the operation /// A representing the running operation diff --git a/src/Tgstation.Server.Host/Components/Chat/IProviderFactory.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IProviderFactory.cs similarity index 80% rename from src/Tgstation.Server.Host/Components/Chat/IProviderFactory.cs rename to src/Tgstation.Server.Host/Components/Chat/Providers/IProviderFactory.cs index 2bf9b1651d..91a83eeb96 100644 --- a/src/Tgstation.Server.Host/Components/Chat/IProviderFactory.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IProviderFactory.cs @@ -1,7 +1,6 @@ using Tgstation.Server.Api.Models.Internal; -using Tgstation.Server.Host.Components.Chat.Providers; -namespace Tgstation.Server.Host.Components.Chat +namespace Tgstation.Server.Host.Components.Chat.Providers { /// /// Factory for s diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs index c200d55f39..3683c39cea 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs @@ -61,12 +61,12 @@ namespace Tgstation.Server.Host.Components.Chat.Providers readonly IrcPasswordType? passwordType; /// - /// Map of s to channel names + /// Map of s to channel names /// readonly Dictionary channelIdMap; /// - /// Map of s to query users + /// Map of s to query users /// readonly Dictionary queryChannelIdMap; @@ -210,9 +210,9 @@ namespace Tgstation.Server.Host.Components.Chat.Providers var message = new Message { Content = e.Data.Message, - User = new User + User = new ChatUser { - Channel = new Channel + Channel = new ChatChannel { ConnectionName = address, FriendlyName = isPrivate ? String.Format(CultureInfo.InvariantCulture, "PM: {0}", channelName) : channelName, @@ -375,7 +375,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers } /// - public override Task> MapChannels(IEnumerable channels, CancellationToken cancellationToken) => Task.Factory.StartNew(() => + public override Task> MapChannels(IEnumerable channels, CancellationToken cancellationToken) => Task.Factory.StartNew(() => { if (channels.Any(x => x.IrcChannel == null)) throw new InvalidOperationException("ChatChannel missing IrcChannel!"); @@ -394,7 +394,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers foreach (var I in hs) client.RfcJoin(I); - return (IReadOnlyCollection)channels.Select(x => + return (IReadOnlyCollection)channels.Select(x => { ulong? id = null; if (!channelIdMap.Any(y => @@ -409,7 +409,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers channelIdMap.Add(id.Value, x.IrcChannel); } - return new Channel + return new ChatChannel { RealId = id.Value, IsAdminChannel = x.IsAdminChannel == true, diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs index 393432cc56..139fe3add0 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs @@ -91,7 +91,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers public abstract Task Disconnect(CancellationToken cancellationToken); /// - public abstract Task> MapChannels(IEnumerable channels, CancellationToken cancellationToken); + public abstract Task> MapChannels(IEnumerable channels, CancellationToken cancellationToken); /// public async Task NextMessage(CancellationToken cancellationToken) diff --git a/src/Tgstation.Server.Host/Components/Chat/ProviderFactory.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/ProviderFactory.cs similarity index 96% rename from src/Tgstation.Server.Host/Components/Chat/ProviderFactory.cs rename to src/Tgstation.Server.Host/Components/Chat/Providers/ProviderFactory.cs index 14f558a593..e31160d1a5 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ProviderFactory.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/ProviderFactory.cs @@ -2,10 +2,9 @@ using System; using System.Globalization; using Tgstation.Server.Api.Models; -using Tgstation.Server.Host.Components.Chat.Providers; using Tgstation.Server.Host.Core; -namespace Tgstation.Server.Host.Components.Chat +namespace Tgstation.Server.Host.Components.Chat.Providers { /// sealed class ProviderFactory : IProviderFactory diff --git a/src/Tgstation.Server.Host/Components/Chat/Response.cs b/src/Tgstation.Server.Host/Components/Chat/Response.cs deleted file mode 100644 index 59be02b4ba..0000000000 --- a/src/Tgstation.Server.Host/Components/Chat/Response.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; - -namespace Tgstation.Server.Host.Components.Chat -{ - /// - /// Represents a chat message requested by DD - /// - sealed class Response - { - /// - /// The message string - /// - public string Message { get; set; } - - /// - /// The list of internal channel ids to send to - /// - public List ChannelIds { get; set; } - } -} diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/ChatMessage.cs b/src/Tgstation.Server.Host/Components/Interop/ChatMessage.cs similarity index 74% rename from src/Tgstation.Server.Host/Components/Interop/Bridge/ChatMessage.cs rename to src/Tgstation.Server.Host/Components/Interop/ChatMessage.cs index 9037e94c8f..ca13d25ce0 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/ChatMessage.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChatMessage.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace Tgstation.Server.Host.Components.Interop.Bridge +namespace Tgstation.Server.Host.Components.Interop { public sealed class ChatMessage { diff --git a/src/Tgstation.Server.Host/Components/Interop/Topic/ChatCommand.cs b/src/Tgstation.Server.Host/Components/Interop/Topic/ChatCommand.cs index 8c47fdea95..ec9a8ea641 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Topic/ChatCommand.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Topic/ChatCommand.cs @@ -19,9 +19,9 @@ namespace Tgstation.Server.Host.Components.Interop.Topic public string Params { get; } /// - /// The that sent the command + /// The that sent the command /// - public User User { get; } + public ChatUser User { get; } /// /// Initializes a new instance of the . @@ -29,7 +29,7 @@ namespace Tgstation.Server.Host.Components.Interop.Topic /// The value of . /// The value of . /// The value of . - public ChatCommand(User user, string command, string parameters) + public ChatCommand(ChatUser user, string command, string parameters) { User = user ?? throw new ArgumentNullException(nameof(user)); Name = command ?? throw new ArgumentNullException(nameof(command)); diff --git a/src/Tgstation.Server.Host/Components/Interop/Topic/EventNotification.cs b/src/Tgstation.Server.Host/Components/Interop/Topic/EventNotification.cs index 48a31622bb..eb6db4236c 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Topic/EventNotification.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Topic/EventNotification.cs @@ -5,13 +5,13 @@ namespace Tgstation.Server.Host.Components.Interop.Topic { sealed class EventNotification { - public EventType EventType { get; } + public EventType Type { get; } public IReadOnlyCollection Parameters { get; } public EventNotification(EventType eventType, IEnumerable parameters = null) { - EventType = eventType; + Type = eventType; Parameters = parameters?.ToList(); } } diff --git a/src/Tgstation.Server.Host/Components/Interop/Topic/TopicResponse.cs b/src/Tgstation.Server.Host/Components/Interop/Topic/TopicResponse.cs index cee18a73d8..d181745d17 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Topic/TopicResponse.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Topic/TopicResponse.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Tgstation.Server.Host.Components.Chat; namespace Tgstation.Server.Host.Components.Interop.Topic { @@ -7,8 +6,8 @@ namespace Tgstation.Server.Host.Components.Interop.Topic { public string ErrorMessage { get; set; } - public string CommandResponse { get; set; } + public string CommandResponseMessage { get; set; } - public ICollection ChatResponses { get; set; } + public ICollection ChatResponses { get; set; } } } diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs index 8efb25659a..65ae20fe7c 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs @@ -447,13 +447,13 @@ namespace Tgstation.Server.Host.Components.Watchdog if (result?.ChatResponses == null) return true; - await Task.WhenAll(result.ChatResponses.Select(x => Chat.SendMessage(x.Message, x.ChannelIds, cancellationToken))).ConfigureAwait(false); + await Task.WhenAll(result.ChatResponses.Select(x => Chat.SendMessage(x.Text, x.ChannelIds, cancellationToken))).ConfigureAwait(false); return true; } /// - public async Task HandleChatCommand(string commandName, string arguments, Chat.User sender, CancellationToken cancellationToken) + public async Task HandleChatCommand(string commandName, string arguments, Chat.ChatUser sender, CancellationToken cancellationToken) { using (await SemaphoreSlimContext.Lock(Semaphore, cancellationToken).ConfigureAwait(false)) { @@ -467,7 +467,7 @@ namespace Tgstation.Server.Host.Components.Watchdog var activeServer = GetActiveController(); var commandResult = await activeServer.SendCommand(command, cancellationToken).ConfigureAwait(false); - return commandResult?.CommandResponse ?? + return commandResult?.CommandResponseMessage ?? (commandResult == null ? "ERROR: Bad topic exchange!" : "ERROR: Bad DMAPI response!"); diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs index cc11929724..c593584c0a 100644 --- a/src/Tgstation.Server.Host/Core/Application.cs +++ b/src/Tgstation.Server.Host/Core/Application.cs @@ -27,6 +27,7 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Components; using Tgstation.Server.Host.Components.Byond; using Tgstation.Server.Host.Components.Chat; +using Tgstation.Server.Host.Components.Chat.Providers; using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Components.Watchdog; using Tgstation.Server.Host.Configuration;