-#[skip_serializing_none]
-#[derive(Clone, Debug, Deserialize, Serialize)]
-#[serde(rename_all = "camelCase")]
-pub struct Note {
- #[serde(rename = "@context")]
- context: OneOrMany<AnyBase>,
- r#type: NoteType,
- id: Url,
- pub(crate) attributed_to: ObjectId<ApubPerson>,
- to: ObjectId<ApubPerson>,
- content: String,
- media_type: MediaTypeHtml,
- source: Source,
- published: Option<DateTime<FixedOffset>>,
- updated: Option<DateTime<FixedOffset>>,
- #[serde(flatten)]
- unparsed: Unparsed,
-}
-
-impl Note {
- pub(crate) fn id_unchecked(&self) -> &Url {
- &self.id
- }
- pub(crate) fn id(&self, expected_domain: &Url) -> Result<&Url, LemmyError> {
- verify_domains_match(&self.id, expected_domain)?;
- Ok(&self.id)
- }
-
- pub(crate) async fn verify(
- &self,
- context: &LemmyContext,
- request_counter: &mut i32,
- ) -> Result<(), LemmyError> {
- verify_domains_match(self.attributed_to.inner(), &self.id)?;
- let person = self
- .attributed_to
- .dereference(context, request_counter)
- .await?;
- if person.banned {
- return Err(anyhow!("Person is banned from site").into());
- }
- Ok(())
- }
-}
-