summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndřej Hruška <ondra@ondrovo.com>2019-10-03 19:24:10 +0200
committerPaul Woolcock <paul@woolcock.us>2020-04-07 12:36:59 -0400
commit3d0ecb9e41da8dd85937b45d87602f96e947acbb (patch)
tree70be47878d710257a0cf1db3c7186151155398b5
parent98932ac5d662f09fd3719994933b3dbc09e3d7e3 (diff)
Add content_type support to StatusBuilder
-rw-r--r--src/status_builder.rs34
1 files changed, 34 insertions, 0 deletions
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<Vec<String>>,
sensitive: Option<bool>,
spoiler_text: Option<String>,
+ content_type: Option<String>,
visibility: Option<Visibility>,
language: Option<Language>,
}
@@ -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("<b>thicc</b>")
+ /// .content_type("text/html")
+ /// .build()?;
+ /// # Ok(())
+ /// # }
+ /// ```
+ pub fn content_type<I: Into<String>>(&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<Visibility>,
#[serde(skip_serializing_if = "Option::is_none")]
language: Option<Language>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ content_type: Option<String>,
}
/// 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);
}