mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-27 15:07:03 +01:00
Rename ChatSettings to ChatBot among other things
This commit is contained in:
+3
-3
@@ -6,16 +6,16 @@ using Tgstation.Server.Api.Rights;
|
||||
namespace Tgstation.Server.Api.Models
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public sealed class ChatSettings : Internal.ChatSettings
|
||||
public sealed class ChatBot : Internal.ChatBot
|
||||
{
|
||||
/// <summary>
|
||||
/// Channels the Discord bot should listen/announce in
|
||||
/// </summary>
|
||||
[Permissions(WriteRight = ChatSettingsRights.WriteChannels)]
|
||||
[Permissions(WriteRight = ChatBotRights.WriteChannels)]
|
||||
public List<ChatChannel> Channels { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Validates <see cref="Channels"/> are correct for the <see cref="Internal.ChatSettings.Provider"/>
|
||||
/// Validates <see cref="Channels"/> are correct for the <see cref="Internal.ChatBot.Provider"/>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool ValidateProviderChannelTypes()
|
||||
@@ -47,10 +47,10 @@ namespace Tgstation.Server.Api.Models
|
||||
public RepositoryRights? RepositoryRights { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Rights.ChatSettingsRights"/> of the <see cref="InstanceUser"/>
|
||||
/// The <see cref="Rights.ChatBotRights"/> of the <see cref="InstanceUser"/>
|
||||
/// </summary>
|
||||
[Required]
|
||||
public ChatSettingsRights? ChatSettingsRights { get; set; }
|
||||
public ChatBotRights? ChatBotRights { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Rights.ConfigurationRights"/> of the <see cref="InstanceUser"/>
|
||||
|
||||
+6
-6
@@ -6,8 +6,8 @@ namespace Tgstation.Server.Api.Models.Internal
|
||||
/// <summary>
|
||||
/// Manage the server chat bots
|
||||
/// </summary>
|
||||
[Model(RightsType.ChatSettings, RequiresInstance = true, CanList = true, CanCrud = true, ReadRight = ChatSettingsRights.Read)]
|
||||
public class ChatSettings
|
||||
[Model(RightsType.ChatBots, RequiresInstance = true, CanList = true, CanCrud = true, ReadRight = ChatBotRights.Read)]
|
||||
public class ChatBot
|
||||
{
|
||||
/// <summary>
|
||||
/// The settings id
|
||||
@@ -18,26 +18,26 @@ namespace Tgstation.Server.Api.Models.Internal
|
||||
/// <summary>
|
||||
/// The name of the connection
|
||||
/// </summary>
|
||||
[Permissions(WriteRight = ChatSettingsRights.WriteName)]
|
||||
[Permissions(WriteRight = ChatBotRights.WriteName)]
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If the connection is enabled
|
||||
/// </summary>
|
||||
[Permissions(WriteRight = ChatSettingsRights.WriteEnabled)]
|
||||
[Permissions(WriteRight = ChatBotRights.WriteEnabled)]
|
||||
public bool? Enabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ChatProvider"/> used for the connection
|
||||
/// </summary>
|
||||
[Permissions(WriteRight = ChatSettingsRights.WriteProvider)]
|
||||
[Permissions(WriteRight = ChatBotRights.WriteProvider)]
|
||||
public ChatProvider? Provider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The information used to connect to the <see cref="Provider"/>
|
||||
/// </summary>
|
||||
[Permissions(ReadRight = ChatSettingsRights.ReadConnectionString, WriteRight = ChatSettingsRights.ReadConnectionString)]
|
||||
[Permissions(ReadRight = ChatBotRights.ReadConnectionString, WriteRight = ChatBotRights.ReadConnectionString)]
|
||||
[Required]
|
||||
public string ConnectionString { get; set; }
|
||||
}
|
||||
+11
-11
@@ -3,49 +3,49 @@
|
||||
namespace Tgstation.Server.Api.Rights
|
||||
{
|
||||
/// <summary>
|
||||
/// Rights for <see cref="Models.ChatSettings"/>
|
||||
/// Rights for <see cref="Models.ChatBot"/>
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ChatSettingsRights : ulong
|
||||
public enum ChatBotRights : ulong
|
||||
{
|
||||
/// <summary>
|
||||
/// User has no rights
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// User can change <see cref="Models.Internal.ChatSettings.Enabled"/>
|
||||
/// User can change <see cref="Models.Internal.ChatBot.Enabled"/>
|
||||
/// </summary>
|
||||
WriteEnabled = 1,
|
||||
/// <summary>
|
||||
/// User can change <see cref="Models.Internal.ChatSettings.Provider"/>
|
||||
/// User can change <see cref="Models.Internal.ChatBot.Provider"/>
|
||||
/// </summary>
|
||||
WriteProvider = 2,
|
||||
/// <summary>
|
||||
/// User can change <see cref="Models.ChatSettings.Channels"/>
|
||||
/// User can change <see cref="Models.ChatBot.Channels"/>
|
||||
/// </summary>
|
||||
WriteChannels = 4,
|
||||
/// <summary>
|
||||
/// User can change <see cref="Models.Internal.ChatSettings.ConnectionString"/>
|
||||
/// User can change <see cref="Models.Internal.ChatBot.ConnectionString"/>
|
||||
/// </summary>
|
||||
WriteConnectionString = 8,
|
||||
/// <summary>
|
||||
/// User can read <see cref="Models.Internal.ChatSettings.ConnectionString"/> requires <see cref="Read"/>
|
||||
/// User can read <see cref="Models.Internal.ChatBot.ConnectionString"/> requires <see cref="Read"/>
|
||||
/// </summary>
|
||||
ReadConnectionString = 16,
|
||||
/// <summary>
|
||||
/// User can read all chat settings except <see cref="Models.Internal.ChatSettings.ConnectionString"/>
|
||||
/// User can read all chat settings except <see cref="Models.Internal.ChatBot.ConnectionString"/>
|
||||
/// </summary>
|
||||
Read = 32,
|
||||
/// <summary>
|
||||
/// User can change <see cref="Models.Internal.ChatSettings.Name"/>
|
||||
/// User can change <see cref="Models.Internal.ChatBot.Name"/>
|
||||
/// </summary>
|
||||
WriteName = 32,
|
||||
/// <summary>
|
||||
/// User can create new <see cref="Models.ChatSettings"/>
|
||||
/// User can create new <see cref="Models.ChatBot"/>
|
||||
/// </summary>
|
||||
Create = 64,
|
||||
/// <summary>
|
||||
/// User can delete <see cref="Models.ChatSettings"/>
|
||||
/// User can delete <see cref="Models.ChatBot"/>
|
||||
/// </summary>
|
||||
Delete = 128
|
||||
}
|
||||
@@ -21,7 +21,7 @@ namespace Tgstation.Server.Api.Rights
|
||||
{ RightsType.Byond, typeof(ByondRights) },
|
||||
{ RightsType.DreamMaker, typeof(DreamMakerRights) },
|
||||
{ RightsType.DreamDaemon, typeof(DreamDaemonRights) },
|
||||
{ RightsType.ChatSettings, typeof(ChatSettingsRights) },
|
||||
{ RightsType.ChatBots, typeof(ChatBotRights) },
|
||||
{ RightsType.Configuration, typeof(ConfigurationRights) },
|
||||
{ RightsType.InstanceUser, typeof(InstanceUserRights) }
|
||||
};
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
/// </summary>
|
||||
DreamDaemon,
|
||||
/// <summary>
|
||||
/// <see cref="ChatSettingsRights"/>
|
||||
/// <see cref="ChatBotRights"/>
|
||||
/// </summary>
|
||||
ChatSettings,
|
||||
ChatBots,
|
||||
/// <summary>
|
||||
/// <see cref="ConfigurationRights"/>
|
||||
/// </summary>
|
||||
|
||||
@@ -17,9 +17,9 @@ namespace Tgstation.Server.Client.Components
|
||||
Task<Byond> Read(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the installed BYOND <see cref="Version"/>
|
||||
/// Updates the <see cref="Byond"/> information
|
||||
/// </summary>
|
||||
/// <param name="version">The <see cref="Byond"/> information to update</param>
|
||||
/// <param name="byond">The <see cref="Byond"/> information to update</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the updated <see cref="Byond"/> information</returns>
|
||||
Task<Byond> Update(Byond byond, CancellationToken cancellationToken);
|
||||
|
||||
+15
-15
@@ -8,37 +8,37 @@ namespace Tgstation.Server.Client.Components
|
||||
/// <summary>
|
||||
/// For managing the chat bots
|
||||
/// </summary>
|
||||
public interface IChatSettingsClient
|
||||
public interface IChatBotsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// List the <see cref="ChatSettings"/>
|
||||
/// List the <see cref="ChatBot"/>
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in a <see cref="IReadOnlyList{T}"/> of the <see cref="ChatSettings"/> of the server</returns>
|
||||
Task<IReadOnlyList<ChatSettings>> List(CancellationToken cancellationToken);
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in a <see cref="IReadOnlyList{T}"/> of the <see cref="ChatBot"/> of the server</returns>
|
||||
Task<IReadOnlyList<ChatBot>> List(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Create a <see cref="ChatSettings"/>
|
||||
/// Create a <see cref="ChatBot"/>
|
||||
/// </summary>
|
||||
/// <param name="settings">The <see cref="ChatSettings"/> to create</param>
|
||||
/// <param name="settings">The <see cref="ChatBot"/> to create</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the new <see cref="ChatSettings"/></returns>
|
||||
Task<ChatSettings> Create(ChatSettings settings, CancellationToken cancellationToken);
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the new <see cref="ChatBot"/></returns>
|
||||
Task<ChatBot> Create(ChatBot settings, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Updates a <see cref="ChatSettings"/> setttings
|
||||
/// Updates a <see cref="ChatBot"/> setttings
|
||||
/// </summary>
|
||||
/// <param name="settings">The <see cref="ChatSettings"/> to update</param>
|
||||
/// <param name="settings">The <see cref="ChatBot"/> to update</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the updated <see cref="ChatSettings"/></returns>
|
||||
Task<ChatSettings> Update(ChatSettings settings, CancellationToken cancellationToken);
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the updated <see cref="ChatBot"/></returns>
|
||||
Task<ChatBot> Update(ChatBot settings, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Delete a <see cref="ChatSettings"/>
|
||||
/// Delete a <see cref="ChatBot"/>
|
||||
/// </summary>
|
||||
/// <param name="settings">The <see cref="ChatSettings"/> to delete</param>
|
||||
/// <param name="settings">The <see cref="ChatBot"/> to delete</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task Delete(ChatSettings settings, CancellationToken cancellationToken);
|
||||
Task Delete(ChatBot settings, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api.Models;
|
||||
using Tgstation.Server.Api.Rights;
|
||||
|
||||
namespace Tgstation.Server.Client.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// For managing <see cref="ConfigurationFile"/> files
|
||||
/// </summary>
|
||||
public interface IConfigurationClient : IRightsClient<ConfigurationRights>
|
||||
public interface IConfigurationClient
|
||||
{
|
||||
/// <summary>
|
||||
/// List configuration files
|
||||
@@ -26,7 +24,7 @@ namespace Tgstation.Server.Client.Components
|
||||
/// <param name="file">The <see cref="ConfigurationFile"/> file to read</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task Read(ConfigurationFile file, CancellationToken cancellationToken);
|
||||
Task<ConfigurationFile> Read(ConfigurationFile file, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Overwrite a <see cref="ConfigurationFile"/> file with integrity checks
|
||||
@@ -34,22 +32,6 @@ namespace Tgstation.Server.Client.Components
|
||||
/// <param name="file">The <see cref="ConfigurationFile"/> file to write</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task Write(ConfigurationFile file, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Create/overwrite a <see cref="ConfigurationFile"/> file
|
||||
/// </summary>
|
||||
/// <param name="file">The <see cref="ConfigurationFile"/> file to write</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task Create(ConfigurationFile file, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Delete a <see cref="ConfigurationFile"/> file
|
||||
/// </summary>
|
||||
/// <param name="file">The <see cref="ConfigurationFile"/> file to delete</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task Delete(ConfigurationFile file, CancellationToken cancellationToken);
|
||||
Task<ConfigurationFile> Write(ConfigurationFile file, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api.Models;
|
||||
using Tgstation.Server.Api.Rights;
|
||||
|
||||
namespace Tgstation.Server.Client.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// For managing <see cref="DreamDaemon"/>
|
||||
/// </summary>
|
||||
public interface IDreamDaemonClient: IRightsClient<DreamDaemonRights>
|
||||
public interface IDreamDaemonClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the <see cref="DreamDaemon"/> represented by the <see cref="IDreamDaemonClient"/>
|
||||
@@ -22,14 +21,14 @@ namespace Tgstation.Server.Client.Components
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task Start(CancellationToken cancellationToken);
|
||||
Task<DreamDaemon> Start(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Shutdown <see cref="DreamDaemon"/>
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task Shutdown(CancellationToken cancellationToken);
|
||||
Task<DreamDaemon> Shutdown(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Update <see cref="DreamDaemon"/>. This may trigger <see cref="Api.Models.Internal.DreamDaemonSettings.SoftRestart"/>
|
||||
@@ -37,6 +36,6 @@ namespace Tgstation.Server.Client.Components
|
||||
/// <param name="dreamDaemon">The <see cref="DreamDaemon"/> to update</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task Update(DreamDaemon dreamDaemon, CancellationToken cancellationToken);
|
||||
Task<DreamDaemon> Update(DreamDaemon dreamDaemon, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,14 +8,14 @@ namespace Tgstation.Server.Client.Components
|
||||
/// <summary>
|
||||
/// For managing the compiler
|
||||
/// </summary>
|
||||
public interface IDreamMakerClient : IRightsClient<DreamMakerRights>
|
||||
public interface IDreamMakerClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the <see cref="DreamMaker"/> represented by the <see cref="IDreamMakerClient"/>
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the <see cref="DreamMaker"/> represented by the <see cref="IDreamMakerClient"/></returns>
|
||||
Task<ChatSettings> Read(CancellationToken cancellationToken);
|
||||
Task<DreamMaker> Read(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the <see cref="DreamMaker"/> setttings
|
||||
|
||||
@@ -39,9 +39,9 @@ namespace Tgstation.Server.Client.Components
|
||||
IInstanceUserClient Users { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Access the <see cref="IChatSettingsClient"/>
|
||||
/// Access the <see cref="IChatBotsClient"/>
|
||||
/// </summary>
|
||||
IChatSettingsClient Chat { get; }
|
||||
IChatBotsClient ChatBots { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Access the <see cref="IDreamMakerClient"/>
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api.Models;
|
||||
using Tgstation.Server.Api.Rights;
|
||||
|
||||
namespace Tgstation.Server.Client.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// For managing <see cref="InstanceUser"/>s
|
||||
/// </summary>
|
||||
public interface IInstanceUserClient : IRightsClient<InstanceUserRights>
|
||||
public interface IInstanceUserClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the <see cref="InstanceUser"/>s in the <see cref="Instance"/>
|
||||
@@ -18,12 +17,20 @@ namespace Tgstation.Server.Client.Components
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in a <see cref="IReadOnlyList{T}"/> of <see cref="InstanceUser"/>s in the instance</returns>
|
||||
Task<IReadOnlyList<InstanceUser>> Read(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Update a <paramref name="instanceUser"/>
|
||||
/// </summary>
|
||||
/// <param name="instanceUser">The <see cref="InstanceUser"/> to update</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task Update(InstanceUser instanceUser, CancellationToken cancellationToken);
|
||||
}
|
||||
/// <summary>
|
||||
/// Update a <paramref name="instanceUser"/>
|
||||
/// </summary>
|
||||
/// <param name="instanceUser">The <see cref="InstanceUser"/> to update</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task<InstanceUser> Update(InstanceUser instanceUser, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Create a <paramref name="instanceUser"/>
|
||||
/// </summary>
|
||||
/// <param name="instanceUser">The <see cref="InstanceUser"/> to create</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task<InstanceUser> Create(InstanceUser instanceUser, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,13 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api.Models;
|
||||
using Tgstation.Server.Api.Rights;
|
||||
|
||||
namespace Tgstation.Server.Client.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// For managing the <see cref="Repository"/>
|
||||
/// </summary>
|
||||
public interface IRepositoryClient : IRightsClient<RepositoryRights>
|
||||
public interface IRepositoryClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the <see cref="Repository"/> represented by the <see cref="IRepositoryClient"/>
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
readonly Dictionary<string, ICommand> builtinCommands;
|
||||
|
||||
/// <summary>
|
||||
/// Map of <see cref="IProvider"/>s in use, keyed by <see cref="ChatSettings.Id"/>
|
||||
/// Map of <see cref="IProvider"/>s in use, keyed by <see cref="ChatBot.Id"/>
|
||||
/// </summary>
|
||||
readonly Dictionary<long, IProvider> providers;
|
||||
|
||||
@@ -64,9 +64,9 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
readonly CancellationTokenSource handlerCts;
|
||||
|
||||
/// <summary>
|
||||
/// The initial <see cref="Models.ChatSettings"/> for the <see cref="Chat"/>
|
||||
/// The initial <see cref="Models.ChatBot"/> for the <see cref="Chat"/>
|
||||
/// </summary>
|
||||
readonly List<Models.ChatSettings> initialChatSettings;
|
||||
readonly List<Models.ChatBot> initialChatBots;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ICustomCommandHandler"/> for the <see cref="ChangeChannels(long, IEnumerable{Api.Models.ChatChannel}, CancellationToken)"/>
|
||||
@@ -79,7 +79,7 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
Task chatHandler;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TaskCompletionSource{TResult}"/> that completes when <see cref="ChatSettings"/> change
|
||||
/// The <see cref="TaskCompletionSource{TResult}"/> that completes when <see cref="ChatBot"/>s change
|
||||
/// </summary>
|
||||
TaskCompletionSource<object> connectionsUpdated;
|
||||
|
||||
@@ -100,14 +100,14 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
/// <param name="ioManager">The value of <see cref="ioManager"/></param>
|
||||
/// <param name="logger">The value of <see cref="logger"/></param>
|
||||
/// <param name="commandFactory">The value of <see cref="commandFactory"/></param>
|
||||
/// <param name="initialChatSettings">The <see cref="IEnumerable{T}"/> used to populate <see cref="initialChatSettings"/></param>
|
||||
public Chat(IProviderFactory providerFactory, IIOManager ioManager, ICommandFactory commandFactory, ILogger<Chat> logger, IEnumerable<Models.ChatSettings> initialChatSettings)
|
||||
/// <param name="initialChatBots">The <see cref="IEnumerable{T}"/> used to populate <see cref="initialChatBots"/></param>
|
||||
public Chat(IProviderFactory providerFactory, IIOManager ioManager, ICommandFactory commandFactory, ILogger<Chat> logger, IEnumerable<Models.ChatBot> initialChatBots)
|
||||
{
|
||||
this.providerFactory = providerFactory ?? throw new ArgumentNullException(nameof(providerFactory));
|
||||
this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
|
||||
this.commandFactory = commandFactory ?? throw new ArgumentNullException(nameof(commandFactory));
|
||||
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
this.initialChatSettings = initialChatSettings?.ToList() ?? throw new ArgumentNullException(nameof(initialChatSettings));
|
||||
this.initialChatBots = initialChatBots?.ToList() ?? throw new ArgumentNullException(nameof(initialChatBots));
|
||||
|
||||
builtinCommands = new Dictionary<string, ICommand>();
|
||||
providers = new Dictionary<long, IProvider>();
|
||||
@@ -129,7 +129,7 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
/// <summary>
|
||||
/// Remove a <see cref="IProvider"/> from <see cref="providers"/> and <see cref="mappedChannels"/> optionally updating the <see cref="trackingContexts"/> as well
|
||||
/// </summary>
|
||||
/// <param name="connectionId">The <see cref="ChatSettings.Id"/> of the <see cref="IProvider"/> to delete</param>
|
||||
/// <param name="connectionId">The <see cref="ChatBot.Id"/> of the <see cref="IProvider"/> to delete</param>
|
||||
/// <param name="updateTrackings">If <see cref="trackingContexts"/> should be update</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the <see cref="IProvider"/> being removed if it exists, <see langword="false"/> otherwise</returns>
|
||||
@@ -375,7 +375,7 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task ChangeSettings(ChatSettings newSettings, CancellationToken cancellationToken)
|
||||
public async Task ChangeSettings(ChatBot newSettings, CancellationToken cancellationToken)
|
||||
{
|
||||
if (newSettings == null)
|
||||
throw new ArgumentNullException(nameof(newSettings));
|
||||
@@ -478,9 +478,9 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
{
|
||||
foreach (var I in commandFactory.GenerateCommands())
|
||||
builtinCommands.Add(I.Name.ToUpperInvariant(), I);
|
||||
await Task.WhenAll(initialChatSettings.Select(x => ChangeSettings(x, cancellationToken))).ConfigureAwait(false);
|
||||
await Task.WhenAll(initialChatBots.Select(x => ChangeSettings(x, cancellationToken))).ConfigureAwait(false);
|
||||
await Task.WhenAll(providers.Select(x => x.Value).Select(x => x.Connect(cancellationToken))).ConfigureAwait(false);
|
||||
await Task.WhenAll(initialChatSettings.Select(x => ChangeChannels(x.Id, x.Channels, cancellationToken))).ConfigureAwait(false);
|
||||
await Task.WhenAll(initialChatBots.Select(x => ChangeChannels(x.Id, x.Channels, cancellationToken))).ConfigureAwait(false);
|
||||
chatHandler = MonitorMessages(handlerCts.Token);
|
||||
started = true;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,6 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IChat CreateChat(IEnumerable<Models.ChatSettings> initialChatSettings) => new Chat(providerFactory, ioManager, commandFactory, loggerFactory.CreateLogger<Chat>(), initialChatSettings);
|
||||
public IChat CreateChat(IEnumerable<Models.ChatBot> initialChatBots) => new Chat(providerFactory, ioManager, commandFactory, loggerFactory.CreateLogger<Chat>(), initialChatBots);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
public interface IChat : IHostedService, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// If a given set of <see cref="ChatSettings"/> is connected
|
||||
/// If a given set of <see cref="ChatBot"/> is connected
|
||||
/// </summary>
|
||||
/// <param name="connectionId">The <see cref="ChatSettings.Id"/> of the connection</param>
|
||||
/// <param name="connectionId">The <see cref="ChatBot.Id"/> of the connection</param>
|
||||
/// <returns><see langword="true"/> if it is connected, <see langword="false"/> otherwise</returns>
|
||||
bool Connected(long connectionId);
|
||||
|
||||
@@ -26,17 +26,17 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
void RegisterCommandHandler(ICustomCommandHandler customCommandHandler);
|
||||
|
||||
/// <summary>
|
||||
/// Change chat settings. If the <see cref="ChatSettings.Id"/> is not currently in use, a new connection will be made instead
|
||||
/// Change chat settings. If the <see cref="ChatBot.Id"/> is not currently in use, a new connection will be made instead
|
||||
/// </summary>
|
||||
/// <param name="newSettings">The new <see cref="ChatSettings"/></param>
|
||||
/// <param name="newSettings">The new <see cref="ChatBot"/></param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation. Will complete immediately if the <see cref="ChatSettings.Enabled"/> property of <paramref name="newSettings"/> is <see langword="false"/></returns>
|
||||
Task ChangeSettings(ChatSettings newSettings, CancellationToken cancellationToken);
|
||||
/// <returns>A <see cref="Task"/> representing the running operation. Will complete immediately if the <see cref="ChatBot.Enabled"/> property of <paramref name="newSettings"/> is <see langword="false"/></returns>
|
||||
Task ChangeSettings(ChatBot newSettings, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Disconnects and deletes a given connection
|
||||
/// </summary>
|
||||
/// <param name="connectionId">The <see cref="ChatSettings.Id"/> of the connection</param>
|
||||
/// <param name="connectionId">The <see cref="ChatBot.Id"/> of the connection</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task DeleteConnection(long connectionId, CancellationToken cancellationToken);
|
||||
@@ -44,7 +44,7 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
/// <summary>
|
||||
/// Change chat channels
|
||||
/// </summary>
|
||||
/// <param name="connectionId">The <see cref="ChatSettings.Id"/> of the connection</param>
|
||||
/// <param name="connectionId">The <see cref="ChatBot.Id"/> of the connection</param>
|
||||
/// <param name="newChannels">An <see cref="IEnumerable{T}"/> of the new list of <see cref="Api.Models.ChatChannel"/>s</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
/// <summary>
|
||||
/// Create a <see cref="IChat"/>
|
||||
/// </summary>
|
||||
/// <param name="initialChatSettings">The initial <see cref="Models.ChatSettings"/> for the <see cref="IChat"/></param>
|
||||
/// <param name="initialChatBots">The initial <see cref="Models.ChatBot"/> for the <see cref="IChat"/></param>
|
||||
/// <returns>A new <see cref="IChat"/></returns>
|
||||
IChat CreateChat(IEnumerable<Models.ChatSettings> initialChatSettings);
|
||||
IChat CreateChat(IEnumerable<Models.ChatBot> initialChatBots);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
/// <summary>
|
||||
/// Create a <see cref="IProvider"/>
|
||||
/// </summary>
|
||||
/// <param name="settings">The <see cref="ChatSettings"/> for the new provider</param>
|
||||
/// <param name="settings">The <see cref="ChatBot"/> containing settings for the new provider</param>
|
||||
/// <returns>A new <see cref="IProvider"/></returns>
|
||||
IProvider CreateProvider(ChatSettings settings);
|
||||
IProvider CreateProvider(ChatBot settings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IProvider CreateProvider(Api.Models.Internal.ChatSettings settings)
|
||||
public IProvider CreateProvider(Api.Models.Internal.ChatBot settings)
|
||||
{
|
||||
if (settings == null)
|
||||
throw new ArgumentNullException(nameof(settings));
|
||||
|
||||
@@ -19,10 +19,10 @@ using Z.EntityFramework.Plus;
|
||||
namespace Tgstation.Server.Host.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="ModelController{TModel}"/> for managing <see cref="Api.Models.ChatSettings"/>
|
||||
/// <see cref="ModelController{TModel}"/> for managing <see cref="Api.Models.ChatBot"/>s
|
||||
/// </summary>
|
||||
[Route("/" + nameof(Components.Chat.Chat))]
|
||||
public sealed class ChatController : ModelController<Api.Models.ChatSettings>
|
||||
public sealed class ChatController : ModelController<Api.Models.ChatBot>
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="IInstanceManager"/> for the <see cref="ChatController"/>
|
||||
@@ -56,8 +56,8 @@ namespace Tgstation.Server.Host.Controllers
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
[TgsAuthorize(ChatSettingsRights.Create)]
|
||||
public override async Task<IActionResult> Create([FromBody] Api.Models.ChatSettings model, CancellationToken cancellationToken)
|
||||
[TgsAuthorize(ChatBotRights.Create)]
|
||||
public override async Task<IActionResult> Create([FromBody] Api.Models.ChatBot model, CancellationToken cancellationToken)
|
||||
{
|
||||
if (model == null)
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
@@ -87,7 +87,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
return BadRequest(new ErrorMessage { Message = "One or more of channels aren't formatted correctly for the given provider!" });
|
||||
|
||||
//try to update das db first
|
||||
var dbModel = new Models.ChatSettings
|
||||
var dbModel = new Models.ChatBot
|
||||
{
|
||||
Name = model.Name,
|
||||
ConnectionString = model.ConnectionString,
|
||||
@@ -97,7 +97,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
Provider = model.Provider,
|
||||
};
|
||||
|
||||
DatabaseContext.ChatSettings.Add(dbModel);
|
||||
DatabaseContext.ChatBots.Add(dbModel);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -122,7 +122,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
catch
|
||||
{
|
||||
//undo the add
|
||||
DatabaseContext.ChatSettings.Remove(dbModel);
|
||||
DatabaseContext.ChatBots.Remove(dbModel);
|
||||
await DatabaseContext.Save(default).ConfigureAwait(false);
|
||||
throw;
|
||||
}
|
||||
@@ -135,24 +135,24 @@ namespace Tgstation.Server.Host.Controllers
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[TgsAuthorize(ChatSettingsRights.Delete)]
|
||||
[TgsAuthorize(ChatBotRights.Delete)]
|
||||
public override async Task<IActionResult> Delete(long id, CancellationToken cancellationToken)
|
||||
{
|
||||
var instance = instanceManager.GetInstance(Instance);
|
||||
await Task.WhenAll(instance.Chat.DeleteConnection(id, cancellationToken), DatabaseContext.ChatSettings.Where(x => x.Id == id).DeleteAsync(cancellationToken)).ConfigureAwait(false);
|
||||
await Task.WhenAll(instance.Chat.DeleteConnection(id, cancellationToken), DatabaseContext.ChatBots.Where(x => x.Id == id).DeleteAsync(cancellationToken)).ConfigureAwait(false);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[TgsAuthorize(ChatSettingsRights.Read)]
|
||||
[TgsAuthorize(ChatBotRights.Read)]
|
||||
public override async Task<IActionResult> List(CancellationToken cancellationToken)
|
||||
{
|
||||
var query = DatabaseContext.ChatSettings.Where(x => x.InstanceId == Instance.Id).Include(x => x.Channels);
|
||||
var query = DatabaseContext.ChatBots.Where(x => x.InstanceId == Instance.Id).Include(x => x.Channels);
|
||||
|
||||
var results = await query.ToListAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var connectionStrings = (AuthenticationContext.GetRight(RightsType.ChatSettings) & (int)ChatSettingsRights.ReadConnectionString) != 0;
|
||||
var connectionStrings = (AuthenticationContext.GetRight(RightsType.ChatBots) & (int)ChatBotRights.ReadConnectionString) != 0;
|
||||
|
||||
if (!connectionStrings)
|
||||
foreach (var I in results)
|
||||
@@ -162,16 +162,16 @@ namespace Tgstation.Server.Host.Controllers
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[TgsAuthorize(ChatSettingsRights.Read)]
|
||||
[TgsAuthorize(ChatBotRights.Read)]
|
||||
public override async Task<IActionResult> GetId(long id, CancellationToken cancellationToken)
|
||||
{
|
||||
var query = DatabaseContext.ChatSettings.Where(x => x.Id == id).Include(x => x.Channels);
|
||||
var query = DatabaseContext.ChatBots.Where(x => x.Id == id).Include(x => x.Channels);
|
||||
|
||||
var results = await query.FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (results == default)
|
||||
return NotFound();
|
||||
|
||||
var connectionStrings = (AuthenticationContext.GetRight(RightsType.ChatSettings) & (int)ChatSettingsRights.ReadConnectionString) != 0;
|
||||
var connectionStrings = (AuthenticationContext.GetRight(RightsType.ChatBots) & (int)ChatBotRights.ReadConnectionString) != 0;
|
||||
|
||||
if (!connectionStrings)
|
||||
results.ConnectionString = null;
|
||||
@@ -180,24 +180,24 @@ namespace Tgstation.Server.Host.Controllers
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[TgsAuthorize(ChatSettingsRights.WriteChannels | ChatSettingsRights.WriteConnectionString | ChatSettingsRights.WriteEnabled | ChatSettingsRights.WriteName | ChatSettingsRights.WriteProvider)]
|
||||
public override async Task<IActionResult> Update([FromBody] Api.Models.ChatSettings model, CancellationToken cancellationToken)
|
||||
[TgsAuthorize(ChatBotRights.WriteChannels | ChatBotRights.WriteConnectionString | ChatBotRights.WriteEnabled | ChatBotRights.WriteName | ChatBotRights.WriteProvider)]
|
||||
public override async Task<IActionResult> Update([FromBody] Api.Models.ChatBot model, CancellationToken cancellationToken)
|
||||
{
|
||||
if (model == null)
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
|
||||
var query = DatabaseContext.ChatSettings.Where(x => x.InstanceId == Instance.Id && x.Id == model.Id).Include(x => x.Channels);
|
||||
var query = DatabaseContext.ChatBots.Where(x => x.InstanceId == Instance.Id && x.Id == model.Id).Include(x => x.Channels);
|
||||
|
||||
var current = await query.FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (current == default)
|
||||
return StatusCode((int)HttpStatusCode.Gone);
|
||||
|
||||
var userRights = (ChatSettingsRights)AuthenticationContext.GetRight(RightsType.ChatSettings);
|
||||
var userRights = (ChatBotRights)AuthenticationContext.GetRight(RightsType.ChatBots);
|
||||
|
||||
bool anySettingsModified = false;
|
||||
|
||||
bool CheckModified<T>(Expression<Func<Api.Models.Internal.ChatSettings, T>> expression, ChatSettingsRights requiredRight)
|
||||
bool CheckModified<T>(Expression<Func<Api.Models.Internal.ChatBot, T>> expression, ChatBotRights requiredRight)
|
||||
{
|
||||
var memberSelectorExpression = (MemberExpression)expression.Body;
|
||||
var property = (PropertyInfo)memberSelectorExpression.Member;
|
||||
@@ -213,11 +213,11 @@ namespace Tgstation.Server.Host.Controllers
|
||||
return false;
|
||||
};
|
||||
|
||||
if (CheckModified(x => x.ConnectionString, ChatSettingsRights.WriteConnectionString)
|
||||
|| CheckModified(x => x.Enabled, ChatSettingsRights.WriteEnabled)
|
||||
|| CheckModified(x => x.Name, ChatSettingsRights.WriteName)
|
||||
|| CheckModified(x => x.Provider, ChatSettingsRights.WriteProvider)
|
||||
|| (model.Channels != null && !userRights.HasFlag(ChatSettingsRights.WriteChannels)))
|
||||
if (CheckModified(x => x.ConnectionString, ChatBotRights.WriteConnectionString)
|
||||
|| CheckModified(x => x.Enabled, ChatBotRights.WriteEnabled)
|
||||
|| CheckModified(x => x.Name, ChatBotRights.WriteName)
|
||||
|| CheckModified(x => x.Provider, ChatBotRights.WriteProvider)
|
||||
|| (model.Channels != null && !userRights.HasFlag(ChatBotRights.WriteChannels)))
|
||||
return Forbid();
|
||||
|
||||
if (model.Channels != null)
|
||||
@@ -239,9 +239,9 @@ namespace Tgstation.Server.Host.Controllers
|
||||
if (model.Channels != null || anySettingsModified)
|
||||
await chat.ChangeChannels(current.Id, current.Channels, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (userRights.HasFlag(ChatSettingsRights.Read))
|
||||
if (userRights.HasFlag(ChatBotRights.Read))
|
||||
{
|
||||
if (!userRights.HasFlag(ChatSettingsRights.ReadConnectionString))
|
||||
if (!userRights.HasFlag(ChatBotRights.ReadConnectionString))
|
||||
current.ConnectionString = null;
|
||||
return Json(current.ToApi());
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
Models.InstanceUser InstanceAdminUser() => new Models.InstanceUser
|
||||
{
|
||||
ByondRights = (ByondRights)~0U,
|
||||
ChatSettingsRights = (ChatSettingsRights)~0U,
|
||||
ChatBotRights = (ChatBotRights)~0U,
|
||||
ConfigurationRights = (ConfigurationRights)~0U,
|
||||
DreamDaemonRights = (DreamDaemonRights)~0U,
|
||||
DreamMakerRights = (DreamMakerRights)~0U,
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
var dbUser = new Models.InstanceUser
|
||||
{
|
||||
ByondRights = model.ByondRights ?? ByondRights.None,
|
||||
ChatSettingsRights = model.ChatSettingsRights ?? ChatSettingsRights.None,
|
||||
ChatBotRights = model.ChatBotRights ?? ChatBotRights.None,
|
||||
ConfigurationRights = model.ConfigurationRights ?? ConfigurationRights.None,
|
||||
DreamDaemonRights = model.DreamDaemonRights ?? DreamDaemonRights.None,
|
||||
DreamMakerRights = model.DreamMakerRights ?? DreamMakerRights.None,
|
||||
@@ -93,7 +93,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
return StatusCode((int)HttpStatusCode.Gone);
|
||||
|
||||
originalUser.ByondRights = model.ByondRights ?? originalUser.ByondRights;
|
||||
originalUser.ChatSettingsRights = model.ChatSettingsRights ?? originalUser.ChatSettingsRights;
|
||||
originalUser.ChatBotRights = model.ChatBotRights ?? originalUser.ChatBotRights;
|
||||
originalUser.ConfigurationRights = model.ConfigurationRights ?? originalUser.ConfigurationRights;
|
||||
originalUser.DreamDaemonRights = model.DreamDaemonRights ?? originalUser.DreamDaemonRights;
|
||||
originalUser.DreamMakerRights = model.DreamMakerRights ?? originalUser.DreamMakerRights;
|
||||
|
||||
@@ -52,10 +52,10 @@ namespace Tgstation.Server.Host.Controllers
|
||||
public TgsAuthorizeAttribute(DreamDaemonRights requiredRights) => Roles = RightsHelper.RoleNames(requiredRights);
|
||||
|
||||
/// <summary>
|
||||
/// Construct a <see cref="TgsAuthorizeAttribute"/> for <see cref="ChatSettingsRights"/>
|
||||
/// Construct a <see cref="TgsAuthorizeAttribute"/> for <see cref="ChatBotRights"/>
|
||||
/// </summary>
|
||||
/// <param name="requiredRights">The rights required</param>
|
||||
public TgsAuthorizeAttribute(ChatSettingsRights requiredRights) => Roles = RightsHelper.RoleNames(requiredRights);
|
||||
public TgsAuthorizeAttribute(ChatBotRights requiredRights) => Roles = RightsHelper.RoleNames(requiredRights);
|
||||
|
||||
/// <summary>
|
||||
/// Construct a <see cref="TgsAuthorizeAttribute"/> for <see cref="ConfigurationRights"/>
|
||||
|
||||
+3
-4
@@ -1,12 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using Tgstation.Server.Api.Models;
|
||||
|
||||
namespace Tgstation.Server.Host.Models
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public sealed class ChatSettings : Api.Models.Internal.ChatSettings, IApiConvertable<Api.Models.ChatSettings>
|
||||
public sealed class ChatBot : Api.Models.Internal.ChatBot, IApiConvertable<Api.Models.ChatBot>
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="Api.Models.Instance.Id"/>
|
||||
@@ -20,12 +19,12 @@ namespace Tgstation.Server.Host.Models
|
||||
public Instance Instance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="Api.Models.ChatSettings.Channels"/>
|
||||
/// See <see cref="Api.Models.ChatBot.Channels"/>
|
||||
/// </summary>
|
||||
public List<ChatChannel> Channels { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Api.Models.ChatSettings ToApi() => new Api.Models.ChatSettings
|
||||
public Api.Models.ChatBot ToApi() => new Api.Models.ChatBot
|
||||
{
|
||||
Channels = Channels.Select(x => x.ToApi()).ToList(),
|
||||
ConnectionString = ConnectionString,
|
||||
@@ -11,14 +11,14 @@ namespace Tgstation.Server.Host.Models
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Api.Models.Internal.ChatSettings.Id"/>
|
||||
/// The <see cref="Api.Models.Internal.ChatBot.Id"/>
|
||||
/// </summary>
|
||||
public long ChatSettingsId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Models.ChatSettings"/>
|
||||
/// The <see cref="Models.ChatBot"/>
|
||||
/// </summary>
|
||||
public ChatSettings ChatSettings { get; set; }
|
||||
public ChatBot ChatSettings { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Api.Models.ChatChannel ToApi() => new Api.Models.ChatChannel
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Tgstation.Server.Host.Models
|
||||
public DbSet<DreamMakerSettings> DreamMakerSettings { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public DbSet<ChatSettings> ChatSettings { get; set; }
|
||||
public DbSet<ChatBot> ChatBots { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public DbSet<DreamDaemonSettings> DreamDaemonSettings { get; set; }
|
||||
@@ -122,7 +122,7 @@ namespace Tgstation.Server.Host.Models
|
||||
chatChannel.HasIndex(x => new { x.ChatSettingsId, x.DiscordChannelId }).IsUnique();
|
||||
chatChannel.HasOne(x => x.ChatSettings).WithMany(x => x.Channels).HasForeignKey(x => x.ChatSettingsId).OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<ChatSettings>().HasIndex(x => x.Name).IsUnique();
|
||||
modelBuilder.Entity<ChatBot>().HasIndex(x => x.Name).IsUnique();
|
||||
|
||||
var instanceModel = modelBuilder.Entity<Instance>();
|
||||
instanceModel.HasIndex(x => x.Path).IsUnique();
|
||||
|
||||
@@ -50,9 +50,9 @@ namespace Tgstation.Server.Host.Models
|
||||
DbSet<DreamDaemonSettings> DreamDaemonSettings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Models.ChatSettings"/> in the <see cref="IDatabaseContext"/>
|
||||
/// The <see cref="Models.ChatBot"/> in the <see cref="IDatabaseContext"/>
|
||||
/// </summary>
|
||||
DbSet<ChatSettings> ChatSettings { get; set; }
|
||||
DbSet<ChatBot> ChatBots { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ChatChannel"/> in the <see cref="IDatabaseContext"/>
|
||||
|
||||
@@ -34,9 +34,9 @@ namespace Tgstation.Server.Host.Models
|
||||
public List<InstanceUser> InstanceUsers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Models.ChatSettings"/>s for the <see cref="Instance"/>
|
||||
/// The <see cref="Models.ChatBot"/>s for the <see cref="Instance"/>
|
||||
/// </summary>
|
||||
public List<ChatSettings> ChatSettings { get; set; }
|
||||
public List<ChatBot> ChatSettings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="RevisionInformation"/>s in the <see cref="Instance"/>
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Tgstation.Server.Host.Models
|
||||
/// If the <see cref="InstanceUser"/> has any instance rights
|
||||
/// </summary>
|
||||
public bool AnyRights => ByondRights != Api.Rights.ByondRights.None ||
|
||||
ChatSettingsRights != Api.Rights.ChatSettingsRights.None ||
|
||||
ChatBotRights != Api.Rights.ChatBotRights.None ||
|
||||
ConfigurationRights != Api.Rights.ConfigurationRights.None ||
|
||||
DreamDaemonRights != Api.Rights.DreamDaemonRights.None ||
|
||||
DreamMakerRights != Api.Rights.DreamMakerRights.None ||
|
||||
@@ -36,7 +36,7 @@ namespace Tgstation.Server.Host.Models
|
||||
public Api.Models.InstanceUser ToApi() => new Api.Models.InstanceUser
|
||||
{
|
||||
ByondRights = ByondRights,
|
||||
ChatSettingsRights = ChatSettingsRights,
|
||||
ChatBotRights = ChatBotRights,
|
||||
ConfigurationRights = ConfigurationRights,
|
||||
DreamDaemonRights = DreamDaemonRights,
|
||||
DreamMakerRights = DreamMakerRights,
|
||||
|
||||
Reference in New Issue
Block a user