add UserRendererService and improve errors

This commit is contained in:
sam 2024-05-28 17:09:50 +02:00
parent 6114f384a0
commit f674d059fd
14 changed files with 607 additions and 25 deletions

View file

@ -13,16 +13,14 @@ public static class DatabaseQueryExtensions
if (Snowflake.TryParse(userRef, out var snowflake))
{
user = await context.Users
.Include(u => u.Members)
.FirstOrDefaultAsync(u => u.Id == snowflake);
if (user != null) return user;
}
user = await context.Users
.Include(u => u.Members)
.FirstOrDefaultAsync(u => u.Username == userRef);
if (user != null) return user;
throw new FoxnounsError.UnknownEntityError(typeof(User));
throw new ApiError.NotFound("No user with that ID or username found.", code: ErrorCode.UserNotFound);
}
public static async Task<Application> GetFrontendApplicationAsync(this DatabaseContext context)