-
-
Notifications
You must be signed in to change notification settings - Fork 89
Add moderation actions table #298
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Zabuzard
commented
Dec 3, 2021
...ication/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationActionsStore.java
Outdated
Show resolved
Hide resolved
Closed
* ban * unban * kick
c793b88
to
5d214eb
Compare
RealYusufIsmail
previously approved these changes
Dec 7, 2021
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.
I have looked thorough it and all looks good.
Tais993
previously requested changes
Dec 8, 2021
application/src/main/java/org/togetherjava/tjbot/commands/moderation/BanCommand.java
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/moderation/KickCommand.java
Outdated
Show resolved
Hide resolved
...ication/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationActionsStore.java
Outdated
Show resolved
Hide resolved
...ication/src/main/java/org/togetherjava/tjbot/commands/moderation/ModerationActionsStore.java
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/commands/moderation/UnbanCommand.java
Outdated
Show resolved
Hide resolved
Kudos, SonarCloud Quality Gate passed! |
Tais993
approved these changes
Dec 9, 2021
RealYusufIsmail
approved these changes
Dec 10, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Implements and closes #297. This is a crucial pre-requisite that blocks a whole list of features that are currently either being developed or in planning:
This feature basically logs each moderation action (ban, kick, mute, ...) in a database table, with all necessary information such as target, author, timestamp, reason and more. This can then be used by other classes later to retrieve information (see list of blocked features).
Details
The implementation adds a new database table
moderation_actions
:which is hidden behind a helper class
ModerationActionsStore
with retrieval methods such as:getActionsByTypeAscending
getActionsByTargetAscending
getActionsByAuthorAscending
findActionByCaseId
(while those methods are not used right now, they will be used very soon by the mentioned features)
to add a new entry, one calls
addAction
Additionally, the store has been integrated into all currently existing commands:
BanCommand
UnbanCommand
KickCommand
so those commands will now also correctly add the entry to the database, when executed.
Notes
The point in time commands call the
addAction
method as of now is slightly off the actual point in time the action is executed.Simplified speaking, we have
while the
ban
command is obviously a rest action that might be executed slightly deferred. That said, we could potentially usein most cases instead (but maybe not all). However, the time will then still be slightly offset (even if its just some milliseconds).
(I wrote it like that to stay consistent with the point in time we have our actual log message being written. So if we should change this, the log also has to go into the
map
call)tl;dr: It is not really possible to get the exact timestamp that the action is executed at. Hence, future methods that are added to
ModerationActionsStore
, such as timestamp-based retrieval (thinking about #280), must be implemented with a time variance in mind (action closest to timestamp ...).Checklist