Moderation: Support appeal cooldowns#435
Conversation
|
Looks good on a first scim, thanks! I'll try to take a closer look in the upcoming days if you don't mind. Or should I wait because draft? |
Felk
left a comment
There was a problem hiding this comment.
Only some minor comments, mostly style. You may ignore individual comments if you disagree. Looks good, thanks!
| /// <summary> | ||
| /// When a user can appeal. If null, the user is never allowed to appeal. | ||
| /// </summary> | ||
| public Instant? AppealDate { get; init; } |
There was a problem hiding this comment.
Can you add a clarification how this value should get interpreted in the case the user isn't banned? Maybe it can just be any value, but that arbitrary value should bear no meaning in that case?
| await _userRepo.SetAppealCooldown(targetUser, expiration); | ||
| await _appealCooldownLogRepo.LogAppealCooldownChange(targetUser.Id, "auto_appeal_cooldown", issuerUser.Id, now, DEFAULT_APPEAL_TIME); |
There was a problem hiding this comment.
to make it impossible to change the appeal cooldown without logging, would it be better to put both into one call somehow? Not sure how example though
| // First ban can be appealed after 1 month by default. | ||
| // I don't want to automatically calculate how many bans the user has had, because some might be joke/mistakes | ||
| // A mod should manually set the next appeal cooldown based on the rules. | ||
| var DEFAULT_APPEAL_TIME = Duration.FromDays(30); | ||
| Instant expiration = now + DEFAULT_APPEAL_TIME; | ||
| await _userRepo.SetAppealCooldown(targetUser, expiration); | ||
| await _appealCooldownLogRepo.LogAppealCooldownChange(targetUser.Id, "auto_appeal_cooldown", issuerUser.Id, now, DEFAULT_APPEAL_TIME); | ||
|
|
There was a problem hiding this comment.
should this entire section only run if isBan?
| string? issuerName = recentLog?.IssuerUserId == null | ||
| ? "<automated>" | ||
| : (await _userRepo.FindById(recentLog.IssuerUserId))?.Name; |
There was a problem hiding this comment.
Might be impossible since we never delete anyone from the users repo as far as I know, but as a safeguard against failing to look up a user, maybe sth. like this?
| string? issuerName = recentLog?.IssuerUserId == null | |
| ? "<automated>" | |
| : (await _userRepo.FindById(recentLog.IssuerUserId))?.Name; | |
| string issuerName = recentLog?.IssuerUserId == null | |
| ? "<automated>" | |
| : (await _userRepo.FindById(recentLog.IssuerUserId))?.Name | |
| ?? $"<unknown user id ${recentLog.IssuerUserId}>"; |
| return new CommandResult { Response = | ||
| targetUser.AppealDate is null | ||
| ? $"{targetUser.Name} is not eligible to appeal. {infoText}" | ||
| : targetUser.AppealDate < _clock.GetCurrentInstant() | ||
| ? $"{targetUser.Name} is eligible to appeal now. {infoText}" | ||
| : $"{targetUser.Name} will be eligible to appeal on {targetUser.AppealDate}. {infoText}" | ||
| }; |
There was a problem hiding this comment.
not sure if dotnet format would like it, but making the ternary nesting a bit more visible with indentation might help a bit:
| return new CommandResult { Response = | |
| targetUser.AppealDate is null | |
| ? $"{targetUser.Name} is not eligible to appeal. {infoText}" | |
| : targetUser.AppealDate < _clock.GetCurrentInstant() | |
| ? $"{targetUser.Name} is eligible to appeal now. {infoText}" | |
| : $"{targetUser.Name} will be eligible to appeal on {targetUser.AppealDate}. {infoText}" | |
| }; | |
| return new CommandResult { Response = | |
| targetUser.AppealDate is null | |
| ? $"{targetUser.Name} is not eligible to appeal. {infoText}" | |
| : targetUser.AppealDate < _clock.GetCurrentInstant() | |
| ? $"{targetUser.Name} is eligible to appeal now. {infoText}" | |
| : $"{targetUser.Name} will be eligible to appeal on {targetUser.AppealDate}. {infoText}" | |
| }; |
Or, given the infoText gets appended anyway, maybe:
| return new CommandResult { Response = | |
| targetUser.AppealDate is null | |
| ? $"{targetUser.Name} is not eligible to appeal. {infoText}" | |
| : targetUser.AppealDate < _clock.GetCurrentInstant() | |
| ? $"{targetUser.Name} is eligible to appeal now. {infoText}" | |
| : $"{targetUser.Name} will be eligible to appeal on {targetUser.AppealDate}. {infoText}" | |
| }; | |
| return new CommandResult { Response = ( | |
| targetUser.AppealDate is null | |
| ? $"{targetUser.Name} is not eligible to appeal." | |
| : targetUser.AppealDate < _clock.GetCurrentInstant() | |
| ? $"{targetUser.Name} is eligible to appeal now." | |
| : $"{targetUser.Name} will be eligible to appeal on {targetUser.AppealDate}." | |
| ) + " " + infoText | |
| }; |
Opening for preliminary reviews as I work on the web side of this