Fix issue with sending private messages to yourself. Fixes #3912 (#4099)

* Fix issue with sending private messages to yourself. Fixes #3912

* Fix clippy.
This commit is contained in:
Dessalines 2023-10-25 05:09:10 -04:00 committed by GitHub
parent c38dfdcd64
commit 0b41ddca58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,7 +18,7 @@ pub async fn get_private_message(
let limit = data.limit;
let unread_only = data.unread_only.unwrap_or_default();
let creator_id = data.creator_id;
let mut messages = PrivateMessageQuery {
let messages = PrivateMessageQuery {
page,
limit,
unread_only,
@ -27,14 +27,6 @@ pub async fn get_private_message(
.list(&mut context.pool(), person_id)
.await?;
// Messages sent by ourselves should be marked as read. The `read` column in database is only
// for the recipient, and shouldnt be exposed to sender.
messages.iter_mut().for_each(|pmv| {
if pmv.creator.id == person_id {
pmv.private_message.read = true
}
});
Ok(Json(PrivateMessagesResponse {
private_messages: messages,
}))