7 pub use lemmy_apub_lib_derive::*;
8 use lemmy_utils::LemmyError;
9 use lemmy_websocket::LemmyContext;
12 #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
14 #[serde(rename = "https://www.w3.org/ns/activitystreams#Public")]
18 #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
19 #[serde(rename_all = "camelCase")]
20 pub struct ActivityCommonFields {
21 #[serde(rename = "@context")]
22 pub context: OneOrMany<AnyBase>,
28 pub unparsed: Unparsed,
31 impl ActivityCommonFields {
32 pub fn id_unchecked(&self) -> &Url {
37 #[async_trait::async_trait(?Send)]
38 pub trait ActivityHandler {
41 context: &LemmyContext,
42 request_counter: &mut i32,
43 ) -> Result<(), LemmyError>;
47 context: &LemmyContext,
48 request_counter: &mut i32,
49 ) -> Result<(), LemmyError>;
50 fn common(&self) -> &ActivityCommonFields;
53 pub fn verify_domains_match(a: &Url, b: &Url) -> Result<(), LemmyError> {
54 if a.domain() != b.domain() {
55 return Err(DomainError.into());
60 pub fn verify_domains_match_opt(a: &Url, b: Option<&Url>) -> Result<(), LemmyError> {
62 return verify_domains_match(a, b2);
67 pub fn verify_urls_match(a: &Url, b: &Url) -> Result<(), LemmyError> {
69 return Err(DomainError.into());