add Message.post_message_view_type to jsonrpc api, to get the real viewtype of a pre-message.

This commit is contained in:
Simon Laux
2025-12-03 17:47:11 +01:00
committed by link2xt
parent 612f3f32aa
commit 74a62ceb0f
2 changed files with 9 additions and 2 deletions

View File

@@ -48,6 +48,9 @@ pub struct MessageObject {
has_location: bool,
has_html: bool,
view_type: MessageViewtype,
/// If message is a Pre-Message,
/// then this returns the viewtype it will have when it is downloaded.
post_message_view_type: Option<MessageViewtype>,
state: u32,
/// An error text, if there is one.
@@ -212,6 +215,7 @@ impl MessageObject {
has_location: message.has_location(),
has_html: message.has_html(),
view_type: message.get_viewtype().into(),
post_message_view_type: message.get_post_message_viewtype().map(Into::into),
state: message
.get_state()
.to_u32()
@@ -683,6 +687,9 @@ pub struct MessageInfo {
rfc724_mid: String,
server_urls: Vec<String>,
hop_info: String,
/// If message is a Pre-Message,
/// then this returns the viewtype it will have when it is downloaded.
post_message_view_type: Option<MessageViewtype>,
}
impl MessageInfo {
@@ -706,6 +713,7 @@ impl MessageInfo {
rfc724_mid: message.rfc724_mid().to_owned(),
server_urls,
hop_info,
post_message_view_type: message.get_post_message_viewtype().map(Into::into),
})
}
}

View File

@@ -861,8 +861,7 @@ impl Message {
/// If message is a Pre-Message,
/// then this returns the viewtype it will have when it is downloaded.
#[cfg(test)]
pub(crate) fn get_post_message_viewtype(&self) -> Option<Viewtype> {
pub fn get_post_message_viewtype(&self) -> Option<Viewtype> {
if self.download_state != DownloadState::Done {
if let Some(viewtype) = self
.param