Repository: zulip/zulip-terminal

Issue:
Pass new `read_by_sender` flag when sending messages
See https://zulip.com/api/send-message#parameter-read_by_sender and https://chat.zulip.org/#narrow/stream/378-api-design/topic/read_by_sender.20flag.20on.20send-message/near/1702407 for details.

Comments:

Patch:
diff --git a/zulipterminal/api_types.py b/zulipterminal/api_types.py
index b341993..7e102e3 100644
--- a/zulipterminal/api_types.py
+++ b/zulipterminal/api_types.py
@@ -93,6 +93,7 @@ class PrivateComposition(TypedDict):
     type: DirectMessageString
     content: str
     to: List[int]  # User ids
+    read_by_sender: bool  # New in ZFL 236, Zulip 8.0
 
 
 class StreamComposition(TypedDict):
@@ -100,6 +101,7 @@ class StreamComposition(TypedDict):
     content: str
     to: str  # stream name  # TODO: Migrate to using int (stream id)
     subject: str  # TODO: Migrate to using topic
+    read_by_sender: bool  # New in ZFL 236, Zulip 8.0
 
 
 Composition = Union[PrivateComposition, StreamComposition]
diff --git a/zulipterminal/model.py b/zulipterminal/model.py
index 72215c8..75f4c06 100644
--- a/zulipterminal/model.py
+++ b/zulipterminal/model.py
@@ -541,6 +541,7 @@ class Model:
                 type="private",
                 to=recipients,
                 content=content,
+                read_by_sender=True,
             )
             response = self.client.send_message(composition)
             display_error_if_present(response, self.controller)
@@ -557,6 +558,7 @@ class Model:
             to=stream,
             subject=topic,
             content=content,
+            read_by_sender=True,
         )
         response = self.client.send_message(composition)
         display_error_if_present(response, self.controller)
diff --git a/zulipterminal/ui_tools/boxes.py b/zulipterminal/ui_tools/boxes.py
index 441eaba..b084ef5 100644
--- a/zulipterminal/ui_tools/boxes.py
+++ b/zulipterminal/ui_tools/boxes.py
@@ -820,6 +820,7 @@ class WriteBox(urwid.Pile):
                         type="private",
                         to=self.recipient_user_ids,
                         content=self.msg_write_box.edit_text,
+                        read_by_sender=True,
                     )
                 elif self.compose_box_status == "open_with_stream":
                     this_draft = StreamComposition(
@@ -827,6 +828,7 @@ class WriteBox(urwid.Pile):
                         to=self.stream_write_box.edit_text,
                         content=self.msg_write_box.edit_text,
                         subject=self.title_write_box.edit_text,
+                        read_by_sender=True,
                     )
                 saved_draft = self.model.session_draft_message()
                 if not saved_draft:


Test patch:
diff --git a/tests/model/test_model.py b/tests/model/test_model.py
index 6b5a18e..43f80ae 100644
--- a/tests/model/test_model.py
+++ b/tests/model/test_model.py
@@ -773,7 +773,7 @@ class TestModel:
 
         result = model.send_private_message(recipients, content)
 
-        req = dict(type="private", to=recipients, content=content)
+        req = dict(type="private", to=recipients, content=content, read_by_sender=True)
         self.client.send_message.assert_called_once_with(req)
 
         assert result == return_value
@@ -810,7 +810,13 @@ class TestModel:
 
         result = model.send_stream_message(stream, topic, content)
 
-        req = dict(type="stream", to=stream, subject=topic, content=content)
+        req = dict(
+            type="stream",
+            to=stream,
+            subject=topic,
+            content=content,
+            read_by_sender=True,
+        )
         self.client.send_message.assert_called_once_with(req)
 
         assert result == return_value