Skip to content

Commit

Permalink
client id in image report notification
Browse files Browse the repository at this point in the history
  • Loading branch information
worldofjoni committed Aug 20, 2023
1 parent 7822594 commit 8f6c6d1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion backend/src/interface/admin_notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub struct ImageReportInfo {
pub negative_rating_count: u32,
/// Image rank after which the images are sorted when shown to the user.
pub get_image_rank: f32,
/// Number of times this image would have to be reported to automatically get hidden (at the current date)
/// Number of times this image would have to be reported to automatically get hidden (at the current date).
pub report_barrier: u32,
/// User that reported the image.
pub client_id: Uuid,
}
6 changes: 6 additions & 0 deletions backend/src/layer/data/mail/mail_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ impl MailSender {
("negative_rating_count", &info.negative_rating_count),
("get_image_rank", &info.get_image_rank),
("report_barrier", &info.report_barrier),
("client_id", &info.client_id),
];

let info_map = info_array_map
Expand Down Expand Up @@ -176,6 +177,10 @@ mod test {
report.contains(info.report_barrier.to_string().as_str()),
"the template must contain all of the information from the report info"
);
assert!(
report.contains(info.client_id.to_string().as_str()),
"the template must contain all of the information from the report info"
);
}

#[tokio::test]
Expand Down Expand Up @@ -217,6 +222,7 @@ mod test {
negative_rating_count: 20,
get_image_rank: 1.0,
report_barrier: 1,
client_id: Uuid::default(),
}
}

Expand Down
1 change: 1 addition & 0 deletions backend/src/layer/data/mail/template.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The image at the url {{image_link}}
with the id {{image_id}}
was reported {{report_count}} times.
Last reported by: {{client_id}}
Reason: {{reason}}
Image automatically hidden: {{image_got_hidden}} ({{report_barrier}} reports needed)

Expand Down
1 change: 1 addition & 0 deletions backend/src/layer/logic/api_command/command_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ where
negative_rating_count: info.downvotes,
get_image_rank: info.rank,
report_barrier: Self::get_report_barrier(info.upload_date),
client_id: auth_info.client_id,
};

self.admin_notification
Expand Down

0 comments on commit 8f6c6d1

Please sign in to comment.