-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Moderation: Support appeal cooldowns #435
base: master
Are you sure you want to change the base?
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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