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_location: bool,
has_html: bool, has_html: bool,
view_type: MessageViewtype, 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, state: u32,
/// An error text, if there is one. /// An error text, if there is one.
@@ -212,6 +215,7 @@ impl MessageObject {
has_location: message.has_location(), has_location: message.has_location(),
has_html: message.has_html(), has_html: message.has_html(),
view_type: message.get_viewtype().into(), view_type: message.get_viewtype().into(),
post_message_view_type: message.get_post_message_viewtype().map(Into::into),
state: message state: message
.get_state() .get_state()
.to_u32() .to_u32()
@@ -683,6 +687,9 @@ pub struct MessageInfo {
rfc724_mid: String, rfc724_mid: String,
server_urls: Vec<String>, server_urls: Vec<String>,
hop_info: 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 { impl MessageInfo {
@@ -706,6 +713,7 @@ impl MessageInfo {
rfc724_mid: message.rfc724_mid().to_owned(), rfc724_mid: message.rfc724_mid().to_owned(),
server_urls, server_urls,
hop_info, 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, /// If message is a Pre-Message,
/// then this returns the viewtype it will have when it is downloaded. /// then this returns the viewtype it will have when it is downloaded.
#[cfg(test)] pub fn get_post_message_viewtype(&self) -> Option<Viewtype> {
pub(crate) fn get_post_message_viewtype(&self) -> Option<Viewtype> {
if self.download_state != DownloadState::Done { if self.download_state != DownloadState::Done {
if let Some(viewtype) = self if let Some(viewtype) = self
.param .param