Skip to content

Commit

Permalink
model/views: refactor: Get stream email address from new endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
rsashank committed Dec 15, 2023
1 parent 4de6dee commit 82035d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions zulipterminal/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,19 @@ def topics_in_stream(self, stream_id: int) -> List[str]:

return list(self.index["topics"][stream_id])

def stream_email_address(self, stream_id: int) -> str:
"""
Return a string containing the email address of a stream.
"""
url = f"/streams/{stream_id}/email_address"

response = self.client.call_endpoint(url, method="GET")

if response.get("result") == "success":
email_address = response.get("email", "")
return str(email_address)
return ""

@staticmethod
def exception_safe_result(future: "Future[str]") -> str:
try:
Expand Down
2 changes: 1 addition & 1 deletion zulipterminal/ui_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ def __init__(self, controller: Any, stream_id: int) -> None:
else "Not Public to Users"
)
member_keys = ", ".join(map(repr, keys_for_command("STREAM_MEMBERS")))
self.stream_email = stream["email_address"]
self.stream_email = controller.model.stream_email_address(stream_id)
email_keys = ", ".join(map(repr, keys_for_command("COPY_STREAM_EMAIL")))

weekly_traffic = stream["stream_weekly_traffic"]
Expand Down

0 comments on commit 82035d7

Please sign in to comment.