-#[derive(Clone, Debug, Deserialize, Serialize)]
-#[serde(rename_all = "camelCase")]
-pub struct Source {
- content: String,
- media_type: MediaTypeMarkdown,
-}
-
-#[derive(Clone, Debug, Deserialize, Serialize)]
-#[serde(rename_all = "camelCase")]
-pub struct ImageObject {
- #[serde(rename = "type")]
- kind: ImageType,
- url: Url,
-}
-
-/// Updated is actually the deletion time
-fn create_tombstone<T>(
- deleted: bool,
- object_id: Url,
- updated: Option<NaiveDateTime>,
- former_type: T,
-) -> Result<Tombstone, LemmyError>
-where
- T: ToString,
-{
- if deleted {
- if let Some(updated) = updated {
- let mut tombstone = Tombstone::new();
- tombstone.set_id(object_id);
- tombstone.set_former_type(former_type.to_string());
- tombstone.set_deleted(convert_datetime(updated));
- Ok(tombstone)
- } else {
- Err(anyhow!("Cant convert to tombstone because updated time was None.").into())
- }
+pub(crate) fn read_from_string_or_source(
+ content: &str,
+ media_type: &Option<MediaTypeMarkdownOrHtml>,
+ source: &Option<Source>,
+) -> String {
+ if let Some(s) = source {
+ // markdown sent by lemmy in source field
+ s.content.clone()
+ } else if media_type == &Some(MediaTypeMarkdownOrHtml::Markdown) {
+ // markdown sent by peertube in content field
+ content.to_string()