diff --git a/src/status_builder.rs b/src/status_builder.rs index e1ce182..15a24eb 100644 --- a/src/status_builder.rs +++ b/src/status_builder.rs @@ -25,6 +25,7 @@ pub struct StatusBuilder { media_ids: Option>, sensitive: Option, spoiler_text: Option, + content_type: Option, visibility: Option, language: Option, } @@ -150,6 +151,35 @@ impl StatusBuilder { self } + /// Set the content type of the post + /// + /// This is a Pleroma and Glitch-soc extension of the API. + /// + /// # Possible values + /// - `text/plain` + /// - `text/html` + /// - `text/markdown` + /// - `text/bbcode` (Pleroma only) + /// + /// The set of supported content types may vary by server. + /// + /// # Example + /// + /// ```rust + /// # use elefren::prelude::*; + /// # fn main() -> Result<(), elefren::Error> { + /// let status = StatusBuilder::new() + /// .status("thicc") + /// .content_type("text/html") + /// .build()?; + /// # Ok(()) + /// # } + /// ``` + pub fn content_type>(&mut self, content_type: I) -> &mut Self { + self.content_type = Some(content_type.into()); + self + } + /// Set the visibility for the post /// /// # Example @@ -215,6 +245,7 @@ impl StatusBuilder { spoiler_text: self.spoiler_text.clone(), visibility: self.visibility.clone(), language: self.language.clone(), + content_type: self.content_type.clone(), }) } } @@ -236,6 +267,8 @@ pub struct NewStatus { visibility: Option, #[serde(skip_serializing_if = "Option::is_none")] language: Option, + #[serde(skip_serializing_if = "Option::is_none")] + content_type: Option, } /// The visibility of a status. @@ -278,6 +311,7 @@ mod tests { spoiler_text: None, visibility: None, language: None, + content_type: None, }; assert_eq!(s, expected); }