Fix bug where users can't be deleted (#648)

* Add username to mod cases if user is deleted

* Add timezone package to docker container

* Remove extra space in migration sql statement

* Changes from self-review
This commit is contained in:
Josh 2023-01-29 22:10:36 -06:00 committed by GitHub
parent 2c2f31ad38
commit 4559d26a54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 170 additions and 83 deletions

View file

@ -21,8 +21,8 @@ public class NewCasePage : BaseLayout
if (type == null) return this.BadRequest();
if (affectedId == null) return this.BadRequest();
this.Type = (CaseType)type;
this.AffectedId = (int)affectedId;
this.Type = type.Value;
this.AffectedId = affectedId.Value;
return this.Page();
}
@ -38,19 +38,19 @@ public class NewCasePage : BaseLayout
reason ??= string.Empty;
modNotes ??= string.Empty;
// this is fucking ugly
// if id is invalid then return bad request
if (!(await ((CaseType)type).IsIdValid((int)affectedId, this.Database))) return this.BadRequest();
if (!await type.Value.IsIdValid((int)affectedId, this.Database)) return this.BadRequest();
ModerationCase @case = new()
{
Type = (CaseType)type,
Type = type.Value,
Reason = reason,
ModeratorNotes = modNotes,
ExpiresAt = expires,
CreatedAt = DateTime.Now,
CreatorId = user.UserId,
AffectedId = (int)affectedId,
CreatorUsername = user.Username,
AffectedId = affectedId.Value,
};
this.Database.Cases.Add(@case);