From 0b41ddca58e1a211780fc0cd9329156577b72eeb Mon Sep 17 00:00:00 2001
From: Dessalines <dessalines@users.noreply.github.com>
Date: Wed, 25 Oct 2023 05:09:10 -0400
Subject: [PATCH] Fix issue with sending private messages to yourself. Fixes
 #3912 (#4099)

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

* Fix clippy.
---
 crates/api_crud/src/private_message/read.rs | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/crates/api_crud/src/private_message/read.rs b/crates/api_crud/src/private_message/read.rs
index 933d410f11..9f289c9116 100644
--- a/crates/api_crud/src/private_message/read.rs
+++ b/crates/api_crud/src/private_message/read.rs
@@ -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,
   }))