|
26 | 26 |
|
27 | 27 | from zulipterminal import unicode_emojis
|
28 | 28 | from zulipterminal.api_types import (
|
| 29 | + RESOLVED_TOPIC_PREFIX, |
29 | 30 | Composition,
|
30 | 31 | EditPropagateMode,
|
31 | 32 | Event,
|
@@ -559,6 +560,30 @@ def update_private_message(self, msg_id: int, content: str) -> bool:
|
559 | 560 | display_error_if_present(response, self.controller)
|
560 | 561 | return response["result"] == "success"
|
561 | 562 |
|
| 563 | + def toggle_topic_resolved_status(self, stream_id: int, topic_name: str) -> bool: |
| 564 | + request: Dict[str, Any] = { |
| 565 | + "anchor": "newest", |
| 566 | + "num_before": 1, |
| 567 | + "num_after": 0, |
| 568 | + "narrow": [ |
| 569 | + {"operator": "sender", "operand": self.user_email}, |
| 570 | + {"operator": "stream", "operand": self.stream_dict[stream_id]["name"]}, |
| 571 | + {"operator": "topic", "operand": topic_name}, |
| 572 | + ], |
| 573 | + } |
| 574 | + response = self.client.get_messages(request) |
| 575 | + if response["messages"] != []: |
| 576 | + topic_msg_id = response["messages"][0]["id"] |
| 577 | + if topic_name.startswith(RESOLVED_TOPIC_PREFIX): |
| 578 | + request = {"message_id": topic_msg_id, "topic": topic_name[2:], "propagate_mode": "change_all"} |
| 579 | + else: |
| 580 | + request = {"message_id": topic_msg_id, "topic": RESOLVED_TOPIC_PREFIX + topic_name, "propagate_mode": "change_all"} |
| 581 | + response = self.client.update_message(request) |
| 582 | + display_error_if_present(response, self.controller) |
| 583 | + else : |
| 584 | + self.controller.report_error("You have not sent any message to the topic.") |
| 585 | + return response["result"] == "success" |
| 586 | + |
562 | 587 | def update_stream_message(
|
563 | 588 | self,
|
564 | 589 | topic: str,
|
|
0 commit comments