Adding a ModlogKindDataType to modlog API endpoint.#6300
Merged
Conversation
This is necessary to add an `All` type to the modlog fetch. I ran into this when adding a dropdown filter for modlogs in the front end, and they're the only one that doesn't include an all fetch type. Notifications work in the same way, with a separated Kind from the DataType in the API. This also potentially allows grouping multiple modlog actions into one, like "actions done on comments", etc. Those can be added later.
Nutomic
reviewed
Jan 27, 2026
| ModRemovePost, | ||
| ModTransferCommunity, | ||
| ModLockComment, | ||
| } |
Member
There was a problem hiding this comment.
Change the name to ModlogKindFilter, much clearer. And change the definition like this:
ModlogKindFilter {
All,
#[serde(untagged)]
Other(ModlogKind)
}
Member
Author
There was a problem hiding this comment.
Nice, hadn't thought of that. I'll see if I can do the same for the notification type too.
Nutomic
reviewed
Jan 27, 2026
| ModlogKindDataType::ModLockComment => { | ||
| query.filter(modlog::kind.eq(ModlogKind::ModLockComment)) | ||
| } | ||
| }; |
Member
There was a problem hiding this comment.
With the change above, you can get rid of all this code and write:
if let ModlogKindFilter::Other(kind) = type_ {
query = query.filter(modlog::kind.eq(type_))
}Plus this way its not necessary to update the enum every time a new modlog variant is added.
dessalines
added a commit
to LemmyNet/lemmy-js-client
that referenced
this pull request
Jan 27, 2026
Backend PR: LemmyNet/lemmy#6300
Nutomic
reviewed
Jan 27, 2026
| // Comments | ||
| let comment_modlog = ModlogQuery { | ||
| type_: Some(ModlogKind::ModRemoveComment), | ||
| type_: Some(ModlogKindFilter::Other(ModlogKind::ModRemoveComment)), |
Member
There was a problem hiding this comment.
You could implement From or Into trait, and then only write Some(ModlogKind::ModRemoveComment.into())
Member
Author
There was a problem hiding this comment.
Not really worth it for a few lines IMO
Nutomic
approved these changes
Jan 27, 2026
dessalines
added a commit
to LemmyNet/lemmy-js-client
that referenced
this pull request
Jan 27, 2026
* Adding the modlog_kind filter Backend PR: LemmyNet/lemmy#6300 * 1.0.0-modlog-kind-all.0 * 1.0.0-modlog-kind-all.2
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
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.
This is necessary to add an
Alltype to the modlog fetch. I ran into this when adding a dropdown filter for modlogs in the front end, and they're the only one that doesn't include an all fetch type.Notifications work in the same way, with a separated Kind enum in the DB, from the DataType fetch in the API, to allow for an
Allfetch.This also potentially allows grouping multiple modlog actions into one, like "actions done on comments", etc. Those can be added later.