diff --git a/src/Tgstation.Server.Api/Models/Byond.cs b/src/Tgstation.Server.Api/Models/Byond.cs index f1b6baebeb..7327b27cbd 100644 --- a/src/Tgstation.Server.Api/Models/Byond.cs +++ b/src/Tgstation.Server.Api/Models/Byond.cs @@ -6,7 +6,7 @@ namespace Tgstation.Server.Api.Models /// /// Represents a BYOND installation /// - [Model(RightsType.Byond)] + [Model(RightsType.Byond, RequiresInstance = true)] public sealed class Byond { /// diff --git a/src/Tgstation.Server.Api/Models/Chat.cs b/src/Tgstation.Server.Api/Models/Chat.cs new file mode 100644 index 0000000000..543eae1230 --- /dev/null +++ b/src/Tgstation.Server.Api/Models/Chat.cs @@ -0,0 +1,71 @@ +using System.Collections.Generic; +using Tgstation.Server.Api.Rights; + +namespace Tgstation.Server.Api.Models +{ + /// + /// Manage the server chat bots + /// + [Model(RightsType.Chat, RequiresInstance = true)] + public sealed class Chat + { + /// + /// If the IRC client is enabled + /// + [Permissions(WriteRight = ChatRights.SetIrcEnabled)] + public bool IrcEnabled { get; set; } + + /// + /// The IRC server name + /// + [Permissions(ReadRight = ChatRights.SetIrcSettings, WriteRight = ChatRights.SetIrcSettings)] + public string IrcHost { get; set; } + + /// + /// The IRC server port + /// + [Permissions(ReadRight = ChatRights.SetIrcSettings, WriteRight = ChatRights.SetIrcSettings)] + public ushort IrcPort { get; set; } + + /// + /// The IRC server NickServ password + /// + [Permissions(ReadRight = ChatRights.SetIrcSettings, WriteRight = ChatRights.SetIrcSettings)] + public string IrcNickServPassword { get; set; } + + /// + /// Channels the IRC client should join/listen/announce in and allow admin commands + /// + [Permissions(WriteRight = ChatRights.SetIrcChannels)] + public List IrcAdminChannels { get; set; } + + /// + /// Channels the IRC client should join/listen/announce in + /// + [Permissions(WriteRight = ChatRights.SetIrcChannels)] + public List IrcGeneralChannels { get; set; } + + /// + /// If the Discord bot is enabled + /// + [Permissions(WriteRight = ChatRights.SetDiscordEnabled)] + public bool DiscordEnabled { get; set; } + + /// + /// The Discord bot token + /// + [Permissions(ReadRight = ChatRights.SetDiscordSettings, WriteRight = ChatRights.SetDiscordSettings)] + public string DiscordBotToken { get; set; } + + /// + /// Channels the Discord bot should listen/announce in and allow admin commands + /// + [Permissions(WriteRight = ChatRights.SetDiscordChannels)] + public List DiscordAdminChannels { get; set; } + /// + /// Channels the Discord bot should listen/announce in + /// + [Permissions(WriteRight = ChatRights.SetDiscordChannels)] + public List DiscordGeneralChannels { get; set; } + } +} diff --git a/src/Tgstation.Server.Api/Models/DreamDaemon.cs b/src/Tgstation.Server.Api/Models/DreamDaemon.cs index b36ee8b8bb..652256ef5b 100644 --- a/src/Tgstation.Server.Api/Models/DreamDaemon.cs +++ b/src/Tgstation.Server.Api/Models/DreamDaemon.cs @@ -7,7 +7,7 @@ namespace Tgstation.Server.Api.Models /// /// Represents an instance of BYOND's DreamDaemon game server. Create action starts the server. Delete action shuts down the server /// - [Model(RightsType.DreamDaemon, CanCrud = true)] + [Model(RightsType.DreamDaemon, CanCrud = true, RequiresInstance = true)] public sealed class DreamDaemon { /// diff --git a/src/Tgstation.Server.Api/Models/DreamMaker.cs b/src/Tgstation.Server.Api/Models/DreamMaker.cs index 7b9d561208..ca1baaea6d 100644 --- a/src/Tgstation.Server.Api/Models/DreamMaker.cs +++ b/src/Tgstation.Server.Api/Models/DreamMaker.cs @@ -6,7 +6,7 @@ namespace Tgstation.Server.Api.Models /// /// Represents the state of the DreamMaker compiler. Create action starts a new compile. Delete action cancels the current compile /// - [Model(RightsType.DreamMaker, ReadRight = DreamMakerRights.Read, CanCrud = true)] + [Model(RightsType.DreamMaker, ReadRight = DreamMakerRights.Read, CanCrud = true, RequiresInstance = true)] public sealed class DreamMaker { /// diff --git a/src/Tgstation.Server.Api/Models/InstanceUser.cs b/src/Tgstation.Server.Api/Models/InstanceUser.cs index 19b7557cd7..7218e9e344 100644 --- a/src/Tgstation.Server.Api/Models/InstanceUser.cs +++ b/src/Tgstation.Server.Api/Models/InstanceUser.cs @@ -5,7 +5,7 @@ namespace Tgstation.Server.Api.Models /// /// Represents a s permissions in an /// - [Model(RightsType.InstanceUser, WriteRight = InstanceUserRights.WriteUsers)] + [Model(RightsType.InstanceUser, WriteRight = InstanceUserRights.WriteUsers, CanList = true, RequiresInstance = true)] public sealed class InstanceUser { /// diff --git a/src/Tgstation.Server.Api/Models/Repository.cs b/src/Tgstation.Server.Api/Models/Repository.cs index b4b08ece85..d4411e7d45 100644 --- a/src/Tgstation.Server.Api/Models/Repository.cs +++ b/src/Tgstation.Server.Api/Models/Repository.cs @@ -6,7 +6,7 @@ namespace Tgstation.Server.Api.Models /// /// Represents a git repository /// - [Model(RightsType.Repository, ReadRight = RepositoryRights.Read)] + [Model(RightsType.Repository, ReadRight = RepositoryRights.Read, RequiresInstance = true)] public sealed class Repository { /// @@ -48,10 +48,8 @@ namespace Tgstation.Server.Api.Models /// /// Associated list of GitHub pull request number -> sha for merged pull requests. Adding a value to this list will merge the latest commit of the pull request numbered by the key /// -#pragma warning disable CA2227 // Collection properties should be read only [Permissions(ComplexWrite = true)] public Dictionary PullRequests { get; set; } -#pragma warning restore CA2227 // Collection properties should be read only /// /// The username to access the git repository with diff --git a/src/Tgstation.Server.Api/Rights/ChatRights.cs b/src/Tgstation.Server.Api/Rights/ChatRights.cs new file mode 100644 index 0000000000..b354e6087f --- /dev/null +++ b/src/Tgstation.Server.Api/Rights/ChatRights.cs @@ -0,0 +1,40 @@ +using System; + +namespace Tgstation.Server.Api.Rights +{ + /// + /// Rights for + /// + [Flags] + public enum ChatRights + { + /// + /// User has no rights + /// + None = 0, + /// + /// User can enable/disable the IRC client + /// + SetIrcEnabled = 1, + /// + /// User can change the IRC settings + /// + SetIrcSettings = 4, + /// + /// User can change the IRC channels + /// + SetIrcChannels = 8, + /// + /// User can enable/disable the Discord bot + /// + SetDiscordEnabled = 16, + /// + /// User can change the Discord settings + /// + SetDiscordSettings = 32, + /// + /// User can change the Discord channels + /// + SetDiscordChannels = 8, + } +} diff --git a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj index e9c7a313a0..55365cd82f 100644 --- a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj +++ b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj @@ -9,10 +9,12 @@ true bin\Release\netstandard2.0\Tgstation.Server.Api.xml + 1701;1702;1705;CA2227 latest + 1701;1702;1705;CA2227 diff --git a/src/Tgstation.Server.Client/Components/IInstanceUserClient.cs b/src/Tgstation.Server.Client/Components/IInstanceUserClient.cs index 68eae0275d..65248e42d5 100644 --- a/src/Tgstation.Server.Client/Components/IInstanceUserClient.cs +++ b/src/Tgstation.Server.Client/Components/IInstanceUserClient.cs @@ -24,6 +24,6 @@ namespace Tgstation.Server.Client.Components /// The to update /// The for the operation /// A representing the running operation - Task UpdateUser(InstanceUser instanceUser, CancellationToken cancellationToken); + Task Update(InstanceUser instanceUser, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/src/Tgstation.Server.Client/Components/ITokenClient.cs b/src/Tgstation.Server.Client/Components/ITokenClient.cs index a563456217..01b9404b8c 100644 --- a/src/Tgstation.Server.Client/Components/ITokenClient.cs +++ b/src/Tgstation.Server.Client/Components/ITokenClient.cs @@ -33,12 +33,12 @@ namespace Tgstation.Server.Client.Components Task> GetAllInfos(CancellationToken cancellationToken); /// - /// Invalidate the specified active designated by + /// Invalidate the specified active /// - /// The of the to invalidate + /// The to invalidate /// The for the operation /// A representing the running operation - Task Invalidate(long tokenId, CancellationToken cancellationToken); + Task Invalidate(Token token, CancellationToken cancellationToken); /// /// Invalidate all active s for a