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.

Discussion:
zulipbot: Hello @sreecharan7, it seems like you have referenced #1456 in your pull request description, but you have not referenced them in your commit message description(s). Referencing an issue in a commit message automatically closes the corresponding issue when the commit is merged, which makes the issue tracker easier to manage.

Please run `git commit --amend` in your command line client to amend your commit message description with `Fixes #1456.`.

An example of a correctly-formatted commit:

```
commit fabd5e450374c8dde65ec35f02140383940fe146
Author: zulipbot
Date:   Sat Mar 18 13:42:40 2017 -0700

    pull requests: Check PR commits reference when issue is referenced.

    Fixes #51.
```

To learn how to write a great commit message, please refer to our [guide](https://zulip.readthedocs.io/en/latest/contributing/version-control.html#commit-messages).

<!-- fixCommitWarning -->


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