|
|
|
@ -1,7 +1,8 @@
|
|
|
|
|
use crate::{
|
|
|
|
|
objects::{community::ApubCommunity, person::ApubPerson, post::ApubPost},
|
|
|
|
|
protocol::{ImageObject, SourceCompat},
|
|
|
|
|
protocol::{ImageObject, Source},
|
|
|
|
|
};
|
|
|
|
|
use activitystreams_kinds::link::LinkType;
|
|
|
|
|
use chrono::{DateTime, FixedOffset};
|
|
|
|
|
use itertools::Itertools;
|
|
|
|
|
use lemmy_apub_lib::{
|
|
|
|
@ -10,6 +11,7 @@ use lemmy_apub_lib::{
|
|
|
|
|
traits::{ActivityHandler, ApubObject},
|
|
|
|
|
values::MediaTypeHtml,
|
|
|
|
|
};
|
|
|
|
|
use lemmy_db_schema::newtypes::DbUrl;
|
|
|
|
|
use lemmy_utils::LemmyError;
|
|
|
|
|
use lemmy_websocket::LemmyContext;
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
@ -39,8 +41,15 @@ pub struct Page {
|
|
|
|
|
pub(crate) cc: Vec<Url>,
|
|
|
|
|
pub(crate) content: Option<String>,
|
|
|
|
|
pub(crate) media_type: Option<MediaTypeHtml>,
|
|
|
|
|
pub(crate) source: Option<SourceCompat>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
#[serde(deserialize_with = "crate::deserialize_skip_error")]
|
|
|
|
|
pub(crate) source: Option<Source>,
|
|
|
|
|
/// deprecated, use attachment field
|
|
|
|
|
pub(crate) url: Option<Url>,
|
|
|
|
|
/// most software uses array type for attachment field, so we do the same. nevertheless, we only
|
|
|
|
|
/// use the first item
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub(crate) attachment: Vec<Attachment>,
|
|
|
|
|
pub(crate) image: Option<ImageObject>,
|
|
|
|
|
pub(crate) comments_enabled: Option<bool>,
|
|
|
|
|
pub(crate) sensitive: Option<bool>,
|
|
|
|
@ -49,6 +58,13 @@ pub struct Page {
|
|
|
|
|
pub(crate) updated: Option<DateTime<FixedOffset>>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
|
pub struct Attachment {
|
|
|
|
|
pub(crate) href: Url,
|
|
|
|
|
pub(crate) r#type: LinkType,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Page {
|
|
|
|
|
/// Only mods can change the post's stickied/locked status. So if either of these is changed from
|
|
|
|
|
/// the current value, it is a mod action and needs to be verified as such.
|
|
|
|
@ -89,6 +105,15 @@ impl Page {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Attachment {
|
|
|
|
|
pub(crate) fn new(url: DbUrl) -> Attachment {
|
|
|
|
|
Attachment {
|
|
|
|
|
href: url.into(),
|
|
|
|
|
r#type: Default::default(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Used for community outbox, so that it can be compatible with Pleroma/Mastodon.
|
|
|
|
|
#[async_trait::async_trait(?Send)]
|
|
|
|
|
impl ActivityHandler for Page {
|
|
|
|
|