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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement reports for private messages #2433
Conversation
79df8c2
to
5f6f33e
Compare
Should be finished, though i havent done any testing of the api code. I really dislike how much copy-pasting of code this involves. I think at least all the Edit: Merged the list report endpoints into a single one now, and moved report count to site. I would also consider merging create/resolve report endpoints into one (with a type param) to simplify the api, but that probably wouldnt simplify the code. |
5a6dd39
to
3bf3b06
Compare
Merging list report endpoints broke api tests. |
crates/api/src/site/reports/list.rs
Outdated
/// | ||
/// If called by an admin, private message reports are also included. | ||
#[async_trait::async_trait(?Send)] | ||
impl Perform for ListReports { |
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.
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.
Okay, reverted the last commit. Still i think the api should look somewhat different.
src/api_routes.rs
Outdated
@@ -18,7 +26,9 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) { | |||
.route("", web::get().to(route_get_crud::<GetSite>)) | |||
// Admin Actions | |||
.route("", web::post().to(route_post_crud::<CreateSite>)) | |||
.route("", web::put().to(route_post_crud::<EditSite>)), | |||
.route("", web::put().to(route_post_crud::<EditSite>)) | |||
.route("/report_count", web::get().to(route_get::<GetReportCount>)) |
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.
Ah so report_count is just getting moved from user
-> admin
scope.
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.
also reverted
src/api_routes.rs
Outdated
@@ -96,7 +106,6 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) { | |||
"/report/resolve", | |||
web::put().to(route_post::<ResolvePostReport>), | |||
) | |||
.route("/report/list", web::get().to(route_get::<ListPostReports>)) |
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.
See comment above, but yeah I think its probably best to preserve these as individual endpoints, so that the front end can still filter on the types.
unique(private_message_id, creator_id) -- users should only be able to report a pm once | ||
); | ||
|
||
create or replace view private_message_report_view as |
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.
No SQL views anymore, this must be done in diesel. There are already examples for how this works for post and comment report views.
edit: ah I see you maybe just copied this as a template from the other examples, but its not necessary.
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.
True, i copied this from other report migrations, but didnt notice that its not used anymore. Removed.
}; | ||
|
||
// TODO: should send message about new report to admins via websocket, but there is only op | ||
// for community mods |
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.
You can just copy paste from the others, 0
is the admin room for "SendModRoomMessage". I don't think I fully tested that on the front end, but might as well have it here to be consistent.
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.
Ah, that wasnt documented anywhere. Btw, as far as i can tell there arent any checks in the code to ensure that JoinModRoom can only be called by moderators for that community (or admin in case of 0). Am i missing something? Otherwise this would be a security issue.
private_message_report_view, | ||
}; | ||
|
||
// TODO: should send message about new report to admins via websocket, but there is only op |
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.
Same here, copy paste from the createpostreport example.
assert_eq!( | ||
inserted_admin.name, | ||
reports[0].resolver.as_ref().unwrap().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.
Perfect, this looks good.
pub private_message_report: PrivateMessageReport, | ||
pub private_message: PrivateMessage, | ||
pub private_message_creator: PersonSafe, | ||
pub creator: PersonSafeAlias1, |
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.
Once I have some time to work on diesel 2.0, we won't need these aliases anymore :)
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.
Looks good, a few suggestions.
Adressed all the comments. |
This reverts commit 3bf3b06.
13b5913
to
b6c14d6
Compare
No description provided.