]> Untitled Git - lemmy.git/commitdiff
Mark own private messages as read in api (fixes #2484) (#2531)
authorNutomic <me@nutomic.com>
Thu, 3 Nov 2022 17:41:44 +0000 (17:41 +0000)
committerGitHub <noreply@github.com>
Thu, 3 Nov 2022 17:41:44 +0000 (13:41 -0400)
crates/api_crud/src/private_message/read.rs

index fbf7621c71266900f1fafc4d6e9a9e3cb1c11f1e..cc03c318268347f2cebf1f9a5476cfdd6975ed92 100644 (file)
@@ -39,6 +39,14 @@ impl PerformCrud for GetPrivateMessages {
     })
     .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
+      }
+    });
+
     // Blank out deleted or removed info
     for pmv in messages
       .iter_mut()