Skip to content

Commit

Permalink
Fix issue with sending private messages to yourself. Fixes LemmyNet#3912
Browse files Browse the repository at this point in the history
 (LemmyNet#4099)

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

* Fix clippy.
  • Loading branch information
dessalines authored Oct 25, 2023
1 parent c38dfdc commit 0b41ddc
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions crates/api_crud/src/private_message/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
}))
Expand Down

0 comments on commit 0b41ddc

Please sign in to comment.