We should not get a full user for the TGS user so CreatedById should never be null

This commit is contained in:
Jordan Dominion
2025-08-17 16:48:44 -04:00
parent 55f5392cc4
commit 4740bfd210
2 changed files with 4 additions and 6 deletions
@@ -25,7 +25,7 @@ namespace Tgstation.Server.Host.GraphQL.Transformers
{
CreatedAt = model.CreatedAt ?? NotNullFallback<DateTimeOffset>(),
CanonicalName = model.CanonicalName ?? NotNullFallback<string>(),
CreatedById = model.CreatedById,
CreatedById = model.CreatedById ?? NotNullFallback<long>(),
Enabled = model.Enabled ?? NotNullFallback<bool>(),
Id = model.Id!.Value,
Name = model.Name ?? NotNullFallback<string>(),
@@ -74,7 +74,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
/// The <see cref="Entity.Id"/> of the <see cref="CreatedBy"/> <see cref="User"/>.
/// </summary>
[IsProjected(true)]
public required long? CreatedById { get; init; }
public required long CreatedById { get; init; }
/// <summary>
/// Implements the <see cref="IUserGroupsDataLoader"/>.
@@ -131,15 +131,13 @@ namespace Tgstation.Server.Host.GraphQL.Types
CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(userAuthority);
if (!CreatedById.HasValue)
return null;
// This one is particular and cannot be data-loaded due to necessitating a different parameter
var user = await userAuthority.InvokeTransformable<Models.User, User, UserTransformer>(
authority => authority.GetId<User>(CreatedById.Value, true, cancellationToken),
authority => authority.GetId<User>(CreatedById, true, cancellationToken),
queryContext);
if (user == null)
throw new InvalidOperationException($"Query for created by of user ID {CreatedById.Value} returned null!");
throw new InvalidOperationException($"Query for created by of user ID {CreatedById} returned null!");
if (user.CanonicalName == Models.User.CanonicalizeName(Models.User.TgsSystemUserName))
return new UserName(user);