mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 22:48:20 +01:00
Remove IApiTransformable and add missing ILegacyApiTransformable to PermissionSet
This commit is contained in:
@@ -609,13 +609,17 @@ namespace Tgstation.Server.Host.Authority
|
||||
/// <param name="user">The <see cref="User"/> that was created or updated.</param>
|
||||
/// <returns>A <see cref="ValueTask"/> representing the running operation.</returns>
|
||||
ValueTask SendUserUpdatedTopics(User user)
|
||||
=> ValueTaskExtensions.WhenAll(
|
||||
{
|
||||
var transformed = new GraphQL.Transformers.UserTransformer()
|
||||
.CompiledExpression(user);
|
||||
return ValueTaskExtensions.WhenAll(
|
||||
GraphQL.Subscriptions.UserSubscriptions.UserUpdatedTopics(
|
||||
user.Require(x => x.Id))
|
||||
.Select(topic => topicEventSender.SendAsync(
|
||||
topic,
|
||||
((IApiTransformable<User, GraphQL.Types.User>)user).ToApi<GraphQL.Transformers.UserTransformer>(),
|
||||
transformed,
|
||||
CancellationToken.None))); // DCT: Operation should always run
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all registered <see cref="User"/>s.
|
||||
|
||||
@@ -275,16 +275,18 @@ namespace Tgstation.Server.Host.Controllers
|
||||
int? pageQuery,
|
||||
int? pageSizeQuery,
|
||||
CancellationToken cancellationToken)
|
||||
where TModel : IApiTransformable<TModel, TApiModel>
|
||||
where TApiModel : notnull
|
||||
where TTransformer : ITransformer<TModel, TApiModel>, new()
|
||||
=> PaginatedImpl(
|
||||
{
|
||||
var transformer = new TTransformer();
|
||||
return PaginatedImpl(
|
||||
queryGenerator,
|
||||
model => model.ToApi<TTransformer>(),
|
||||
model => transformer.CompiledExpression(model),
|
||||
null,
|
||||
pageQuery,
|
||||
pageSizeQuery,
|
||||
cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a paginated response.
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Host.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a host-side model that may be transformed into a <typeparamref name="TApiModel"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="TModel">The internal model <see cref="Type"/>.</typeparam>
|
||||
/// <typeparam name="TApiModel">The API model <see cref="Type"/>.</typeparam>
|
||||
public interface IApiTransformable<TModel, TApiModel>
|
||||
where TApiModel : notnull
|
||||
where TModel : IApiTransformable<TModel, TApiModel>
|
||||
{
|
||||
/// <summary>
|
||||
/// Convert the <see cref="IApiTransformable{TModel, TApiModel}"/> to it's <typeparamref name="TApiModel"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="TTransformer">The <see cref="ITransformer{TModel, TApiModel}"/> <see cref="Type"/>.</typeparam>
|
||||
/// <returns>A new <typeparamref name="TApiModel"/> based on the <see cref="IApiTransformable{TModel, TApiModel}"/>.</returns>
|
||||
TApiModel ToApi<TTransformer>()
|
||||
where TTransformer : ITransformer<TModel, TApiModel>, new()
|
||||
=> new TTransformer()
|
||||
.CompiledExpression((TModel)this);
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,7 @@ namespace Tgstation.Server.Host.Models
|
||||
{
|
||||
/// <inheritdoc cref="Api.Models.OAuthConnection" />
|
||||
public sealed class OAuthConnection : Api.Models.OAuthConnection,
|
||||
ILegacyApiTransformable<Api.Models.OAuthConnection>,
|
||||
IApiTransformable<OAuthConnection, GraphQL.Types.OAuth.OAuthConnection>
|
||||
ILegacyApiTransformable<Api.Models.OAuthConnection>
|
||||
{
|
||||
/// <summary>
|
||||
/// The row Id.
|
||||
|
||||
@@ -4,8 +4,7 @@ namespace Tgstation.Server.Host.Models
|
||||
{
|
||||
/// <inheritdoc cref="Api.Models.OidcConnection" />
|
||||
public sealed class OidcConnection : Api.Models.OidcConnection,
|
||||
ILegacyApiTransformable<Api.Models.OidcConnection>,
|
||||
IApiTransformable<OidcConnection, GraphQL.Types.OAuth.OidcConnection>
|
||||
ILegacyApiTransformable<Api.Models.OidcConnection>
|
||||
{
|
||||
/// <summary>
|
||||
/// The row Id.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Tgstation.Server.Host.Models
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public sealed class PermissionSet : Api.Models.PermissionSet, IApiTransformable<PermissionSet, GraphQL.Types.PermissionSet>
|
||||
public sealed class PermissionSet : Api.Models.PermissionSet, ILegacyApiTransformable<Api.Models.PermissionSet>
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="Api.Models.EntityId.Id"/> of <see cref="User"/>.
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
using System;
|
||||
|
||||
using Tgstation.Server.Api.Models.Response;
|
||||
|
||||
namespace Tgstation.Server.Host.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="User"/> that has been updated.
|
||||
/// </summary>
|
||||
public sealed class UpdatedUser :
|
||||
IApiTransformable<UpdatedUser, UserResponse>,
|
||||
IApiTransformable<UpdatedUser, GraphQL.Types.UpdatedUser>
|
||||
public sealed class UpdatedUser
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="User"/>'s <see cref="Api.Models.EntityId.Id"/>.
|
||||
|
||||
@@ -8,10 +8,7 @@ using Tgstation.Server.Api.Models.Response;
|
||||
namespace Tgstation.Server.Host.Models
|
||||
{
|
||||
/// <inheritdoc cref="Api.Models.Internal.UserModelBase" />
|
||||
public sealed class User : Api.Models.Internal.UserModelBase,
|
||||
IApiTransformable<User, UserResponse>,
|
||||
IApiTransformable<User, GraphQL.Types.User>,
|
||||
IApiTransformable<User, GraphQL.Types.UserName>
|
||||
public sealed class User : Api.Models.Internal.UserModelBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Username used when creating jobs automatically.
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Tgstation.Server.Host.Models
|
||||
/// <summary>
|
||||
/// Represents a group of <see cref="User"/>s.
|
||||
/// </summary>
|
||||
public sealed class UserGroup : NamedEntity, ILegacyApiTransformable<UserGroupResponse>, IApiTransformable<UserGroup, GraphQL.Types.UserGroup>
|
||||
public sealed class UserGroup : NamedEntity, ILegacyApiTransformable<UserGroupResponse>
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="Models.PermissionSet"/> the <see cref="UserGroup"/> has.
|
||||
|
||||
Reference in New Issue
Block a user