From 97435c68f01147bee6f86353281abdded5b81b7b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Aug 2025 17:26:32 -0400 Subject: [PATCH] Implement projectable GetId for UserGroup --- .../Authority/IUserGroupAuthority.cs | 10 ++++++++++ .../Authority/UserGroupAuthority.cs | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/Tgstation.Server.Host/Authority/IUserGroupAuthority.cs b/src/Tgstation.Server.Host/Authority/IUserGroupAuthority.cs index 635da01353..ab167b87dc 100644 --- a/src/Tgstation.Server.Host/Authority/IUserGroupAuthority.cs +++ b/src/Tgstation.Server.Host/Authority/IUserGroupAuthority.cs @@ -33,6 +33,16 @@ namespace Tgstation.Server.Host.Authority [TgsAuthorize(AdministrationRights.ReadUsers)] RequirementsGated> GetId(long id, bool includeJoins, CancellationToken cancellationToken); + /// + /// Gets the with a given . + /// + /// The result type after projection. + /// The of the . + /// The for the operation. + /// A for . + RequirementsGated> GetId(long id, CancellationToken cancellationToken) + where TResult : notnull; + /// /// Gets all registered s. /// diff --git a/src/Tgstation.Server.Host/Authority/UserGroupAuthority.cs b/src/Tgstation.Server.Host/Authority/UserGroupAuthority.cs index 27ea03feda..78c643a328 100644 --- a/src/Tgstation.Server.Host/Authority/UserGroupAuthority.cs +++ b/src/Tgstation.Server.Host/Authority/UserGroupAuthority.cs @@ -111,6 +111,23 @@ namespace Tgstation.Server.Host.Authority return new AuthorityResponse(userGroup); }); + /// + public RequirementsGated> GetId(long id, CancellationToken cancellationToken) + where TResult : notnull + => new( + () => Flag(AdministrationRights.ReadUsers), + () => Projectable.Create( + QueryableImpl(true) + .Where(x => x.Id == id), + projectable => + { + if (projectable == null) + return Gone(); + + return new AuthorityResponse(projectable.Result); + }, + cancellationToken)); + /// public RequirementsGated> Read(CancellationToken cancellationToken) where TResult : notnull