mirror of
https://github.com/chatmail/core.git
synced 2026-05-21 07:46:31 +03:00
api!: jsonrpc misc_set_draft now requires setting the viewtype
This commit is contained in:
@@ -2033,13 +2033,19 @@ impl CommandApi {
|
|||||||
text: Option<String>,
|
text: Option<String>,
|
||||||
file: Option<String>,
|
file: Option<String>,
|
||||||
quoted_message_id: Option<u32>,
|
quoted_message_id: Option<u32>,
|
||||||
|
view_type: Option<MessageViewtype>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let ctx = self.get_context(account_id).await?;
|
let ctx = self.get_context(account_id).await?;
|
||||||
let mut draft = Message::new(if file.is_some() {
|
let mut draft = Message::new(view_type.map_or_else(
|
||||||
Viewtype::File
|
|| {
|
||||||
} else {
|
if file.is_some() {
|
||||||
Viewtype::Text
|
Viewtype::File
|
||||||
});
|
} else {
|
||||||
|
Viewtype::Text
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|v| v.into(),
|
||||||
|
));
|
||||||
draft.set_text(text.unwrap_or_default());
|
draft.set_text(text.unwrap_or_default());
|
||||||
if let Some(file) = file {
|
if let Some(file) = file {
|
||||||
draft.set_file(file, None);
|
draft.set_file(file, None);
|
||||||
|
|||||||
@@ -160,11 +160,12 @@ class Chat:
|
|||||||
text: Optional[str] = None,
|
text: Optional[str] = None,
|
||||||
file: Optional[str] = None,
|
file: Optional[str] = None,
|
||||||
quoted_msg: Optional[int] = None,
|
quoted_msg: Optional[int] = None,
|
||||||
|
viewtype: Optional[str] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set draft message."""
|
"""Set draft message."""
|
||||||
if isinstance(quoted_msg, Message):
|
if isinstance(quoted_msg, Message):
|
||||||
quoted_msg = quoted_msg.id
|
quoted_msg = quoted_msg.id
|
||||||
self._rpc.misc_set_draft(self.account.id, self.id, text, file, quoted_msg)
|
self._rpc.misc_set_draft(self.account.id, self.id, text, file, quoted_msg, viewtype)
|
||||||
|
|
||||||
def remove_draft(self) -> None:
|
def remove_draft(self) -> None:
|
||||||
"""Remove draft message."""
|
"""Remove draft message."""
|
||||||
|
|||||||
Reference in New Issue
Block a user