]> Untitled Git - lemmy.git/commitdiff
Replace activitystreams crate with activitystreams-kinds
authorFelix Ableitner <me@nutomic.com>
Fri, 19 Nov 2021 17:47:06 +0000 (18:47 +0100)
committerFelix Ableitner <me@nutomic.com>
Mon, 22 Nov 2021 13:28:57 +0000 (14:28 +0100)
68 files changed:
Cargo.lock
crates/apub/Cargo.toml
crates/apub/src/activities/comment/create_or_update.rs
crates/apub/src/activities/community/add_mod.rs
crates/apub/src/activities/community/announce.rs
crates/apub/src/activities/community/block_user.rs
crates/apub/src/activities/community/remove_mod.rs
crates/apub/src/activities/community/report.rs
crates/apub/src/activities/community/undo_block_user.rs
crates/apub/src/activities/community/update.rs
crates/apub/src/activities/deletion/delete.rs
crates/apub/src/activities/deletion/undo_delete.rs
crates/apub/src/activities/following/accept.rs
crates/apub/src/activities/following/follow.rs
crates/apub/src/activities/following/undo_follow.rs
crates/apub/src/activities/mod.rs
crates/apub/src/activities/post/create_or_update.rs
crates/apub/src/activities/private_message/delete.rs
crates/apub/src/activities/private_message/undo_delete.rs
crates/apub/src/activities/voting/undo_vote.rs
crates/apub/src/activities/voting/vote.rs
crates/apub/src/collections/community_moderators.rs
crates/apub/src/collections/community_outbox.rs
crates/apub/src/context.rs
crates/apub/src/fetcher/user_or_community.rs
crates/apub/src/mentions.rs
crates/apub/src/objects/comment.rs
crates/apub/src/objects/community.rs
crates/apub/src/objects/person.rs
crates/apub/src/objects/post.rs
crates/apub/src/protocol/activities/community/add_mod.rs
crates/apub/src/protocol/activities/community/announce.rs
crates/apub/src/protocol/activities/community/block_user.rs
crates/apub/src/protocol/activities/community/mod.rs
crates/apub/src/protocol/activities/community/remove_mod.rs
crates/apub/src/protocol/activities/community/report.rs
crates/apub/src/protocol/activities/community/undo_block_user.rs
crates/apub/src/protocol/activities/community/update.rs
crates/apub/src/protocol/activities/create_or_update/comment.rs
crates/apub/src/protocol/activities/create_or_update/mod.rs
crates/apub/src/protocol/activities/create_or_update/post.rs
crates/apub/src/protocol/activities/deletion/delete.rs
crates/apub/src/protocol/activities/deletion/mod.rs
crates/apub/src/protocol/activities/deletion/undo_delete.rs
crates/apub/src/protocol/activities/following/accept.rs
crates/apub/src/protocol/activities/following/follow.rs
crates/apub/src/protocol/activities/following/mod.rs
crates/apub/src/protocol/activities/following/undo_follow.rs
crates/apub/src/protocol/activities/private_message/create_or_update.rs
crates/apub/src/protocol/activities/private_message/delete.rs
crates/apub/src/protocol/activities/private_message/mod.rs
crates/apub/src/protocol/activities/private_message/undo_delete.rs
crates/apub/src/protocol/activities/voting/mod.rs
crates/apub/src/protocol/activities/voting/undo_vote.rs
crates/apub/src/protocol/activities/voting/vote.rs
crates/apub/src/protocol/collections/group_followers.rs
crates/apub/src/protocol/collections/group_moderators.rs
crates/apub/src/protocol/collections/group_outbox.rs
crates/apub/src/protocol/collections/mod.rs
crates/apub/src/protocol/collections/person_outbox.rs
crates/apub/src/protocol/mod.rs
crates/apub/src/protocol/objects/chat_message.rs
crates/apub/src/protocol/objects/group.rs
crates/apub/src/protocol/objects/mod.rs
crates/apub/src/protocol/objects/note.rs
crates/apub/src/protocol/objects/page.rs
crates/apub/src/protocol/objects/person.rs
crates/apub/src/protocol/objects/tombstone.rs

index 32545d2ae90724bb2e7b9e8684d9158b08f7ffcf..abb5013592e86c7970e15055713e9a1e2bec0cdc 100644 (file)
@@ -16,6 +16,16 @@ dependencies = [
  "url",
 ]
 
+[[package]]
+name = "activitystreams-kinds"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0784e99afd032199d3ed70cefb8eb3a8d1aef15f7f2c4e68d033c4e12bb6079e"
+dependencies = [
+ "serde",
+ "url",
+]
+
 [[package]]
 name = "actix"
 version = "0.12.0"
@@ -1842,7 +1852,7 @@ dependencies = [
 name = "lemmy_apub"
 version = "0.14.1"
 dependencies = [
- "activitystreams",
+ "activitystreams-kinds",
  "actix",
  "actix-rt",
  "actix-web",
index 94684413bd83ca39eac207b62618b4120a13cda8..b4ddff281456c49b52e818479096ae7aafe8096e 100644 (file)
@@ -21,7 +21,7 @@ lemmy_db_views_actor = { version = "=0.14.1", path = "../db_views_actor" }
 lemmy_api_common = { version = "=0.14.1", path = "../api_common" }
 lemmy_websocket = { version = "=0.14.1", path = "../websocket" }
 diesel = "1.4.8"
-activitystreams = "0.7.0-alpha.11"
+activitystreams-kinds = "0.1.2"
 bcrypt = "0.10.1"
 chrono = { version = "0.4.19", features = ["serde"] }
 serde_json = { version = "1.0.68", features = ["preserve_order"] }
index ad686251ba697e0880cc6cffae6ea4208378ae8b..14fc14014f974ee66b601cc70cc2c84590b11b82 100644 (file)
@@ -12,7 +12,7 @@ use crate::{
   objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson},
   protocol::activities::{create_or_update::comment::CreateOrUpdateComment, CreateOrUpdateType},
 };
-use activitystreams::{link::LinkExt, public};
+use activitystreams_kinds::public;
 use lemmy_api_common::{blocking, check_post_deleted_or_removed};
 use lemmy_apub_lib::{
   data::Data,
@@ -65,9 +65,8 @@ impl CreateOrUpdateComment {
     let tagged_users: Vec<ObjectId<ApubPerson>> = create_or_update
       .tag
       .iter()
-      .map(|t| t.href())
-      .flatten()
-      .map(|t| ObjectId::new(t.clone()))
+      .map(|t| t.href.clone())
+      .map(ObjectId::new)
       .collect();
     let mut inboxes = vec![];
     for t in tagged_users {
index 7437750db2bb3de04d7696b6abeec146c79dd031..c244f652de1b90f9ad84d99f273ddec9c234b3b8 100644 (file)
@@ -17,7 +17,7 @@ use crate::{
   objects::{community::ApubCommunity, person::ApubPerson},
   protocol::activities::community::add_mod::AddMod,
 };
-use activitystreams::{activity::kind::AddType, public};
+use activitystreams_kinds::{activity::AddType, public};
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
index 9d76b5240efd238a04d7accb46ee5ad922e3d0ce..2784039bca7a7b0f184922243532cd2d115dcc6a 100644 (file)
@@ -6,7 +6,7 @@ use crate::{
   objects::community::ApubCommunity,
   protocol::activities::{community::announce::AnnounceActivity, CreateOrUpdateType},
 };
-use activitystreams::{activity::kind::AnnounceType, public};
+use activitystreams_kinds::{activity::AnnounceType, public};
 use lemmy_apub_lib::{
   data::Data,
   object_id::ObjectId,
index 0dbf47b3c074b7878b205ec40da73a90f3ba6f34..0442fcc47c60794fa2df927c9b45a73b592d12d9 100644 (file)
@@ -11,7 +11,7 @@ use crate::{
   objects::{community::ApubCommunity, person::ApubPerson},
   protocol::activities::community::block_user::BlockUserFromCommunity,
 };
-use activitystreams::{activity::kind::BlockType, public};
+use activitystreams_kinds::{activity::BlockType, public};
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
index 985a2192245eb3782aef31770aa1a0451ab1dad7..36312070596671199e78dd941258156410b83544 100644 (file)
@@ -17,7 +17,7 @@ use crate::{
   objects::{community::ApubCommunity, person::ApubPerson},
   protocol::activities::community::remove_mod::RemoveMod,
 };
-use activitystreams::{activity::kind::RemoveType, public};
+use activitystreams_kinds::{activity::RemoveType, public};
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
index f0be3e0a04d913f1f1c3734a396a1d686d87d9d5..7207af618fbe9f1a798f2b7d1324b696ba208771 100644 (file)
@@ -9,7 +9,7 @@ use crate::{
   protocol::activities::community::report::Report,
   PostOrComment,
 };
-use activitystreams::activity::kind::FlagType;
+use activitystreams_kinds::activity::FlagType;
 use lemmy_api_common::{blocking, comment::CommentReportResponse, post::PostReportResponse};
 use lemmy_apub_lib::{
   data::Data,
index 4aabb1d4cd0fcd8a6651b614f7b9209bfcdaeedd..dbd6c5d5007d783dbbe0eff64e70b5fad0b09d89 100644 (file)
@@ -14,7 +14,7 @@ use crate::{
     undo_block_user::UndoBlockUserFromCommunity,
   },
 };
-use activitystreams::{activity::kind::UndoType, public};
+use activitystreams_kinds::{activity::UndoType, public};
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
index e625fe0c74c0c8fc0aed3e2fc76ee407d289f6ed..7b2af3c47aa01e85b1f084612308528369f5e235 100644 (file)
@@ -11,7 +11,7 @@ use crate::{
   objects::{community::ApubCommunity, person::ApubPerson},
   protocol::activities::community::update::UpdateCommunity,
 };
-use activitystreams::{activity::kind::UpdateType, public};
+use activitystreams_kinds::{activity::UpdateType, public};
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
index b976a1b4614ce09611003fa967dc48d988837e48..e50cfd85229a10153bca30058f51ae2f1b54f023 100644 (file)
@@ -10,7 +10,7 @@ use crate::{
   objects::{community::ApubCommunity, person::ApubPerson},
   protocol::activities::deletion::delete::Delete,
 };
-use activitystreams::{activity::kind::DeleteType, public};
+use activitystreams_kinds::{activity::DeleteType, public};
 use anyhow::anyhow;
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
index 28ad0f5a345f814e5456c700dc6654e13b576091..8a867fbc2d97346ce7431e36cc70aed2c42f4456 100644 (file)
@@ -10,7 +10,7 @@ use crate::{
   objects::{community::ApubCommunity, person::ApubPerson},
   protocol::activities::deletion::{delete::Delete, undo_delete::UndoDelete},
 };
-use activitystreams::{activity::kind::UndoType, public};
+use activitystreams_kinds::{activity::UndoType, public};
 use anyhow::anyhow;
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
index 15e1f2b4ae1c995bc75f7e89c03f2dae849a17ad..6febd7d432170609ccda54a9425b3b79c00c7572 100644 (file)
@@ -2,7 +2,7 @@ use crate::{
   activities::{generate_activity_id, send_lemmy_activity, verify_activity},
   protocol::activities::following::{accept::AcceptFollowCommunity, follow::FollowCommunity},
 };
-use activitystreams::activity::kind::AcceptType;
+use activitystreams_kinds::activity::AcceptType;
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
index 43c600284a79cfb53a24b1ee6c9f8d5574a0cca9..a5c2e77f02bb8f0fae410fc4eae3de753b8c232a 100644 (file)
@@ -9,7 +9,7 @@ use crate::{
   objects::{community::ApubCommunity, person::ApubPerson},
   protocol::activities::following::{accept::AcceptFollowCommunity, follow::FollowCommunity},
 };
-use activitystreams::activity::kind::FollowType;
+use activitystreams_kinds::activity::FollowType;
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
index 2a3483d450c191c0f190ec125c98787c44101255..c7b926a2b355a0ffc27270313695a62f34bef7d4 100644 (file)
@@ -3,7 +3,7 @@ use crate::{
   objects::{community::ApubCommunity, person::ApubPerson},
   protocol::activities::following::{follow::FollowCommunity, undo_follow::UndoFollowCommunity},
 };
-use activitystreams::activity::kind::UndoType;
+use activitystreams_kinds::activity::UndoType;
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
index cac5d6e1e863b2ebe1237bc9df2e92cd0032cd74..07fc39d2f4411db328240ab95c76a74615b62e21 100644 (file)
@@ -5,7 +5,7 @@ use crate::{
   insert_activity,
   objects::{community::ApubCommunity, person::ApubPerson},
 };
-use activitystreams::public;
+use activitystreams_kinds::public;
 use anyhow::anyhow;
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
index 84c185bef955d2b5254b35109d8f7514af25d137..2e9c8071d5e38e8058131976f45f1ae0e9ff2581 100644 (file)
@@ -12,7 +12,7 @@ use crate::{
   objects::{community::ApubCommunity, person::ApubPerson, post::ApubPost},
   protocol::activities::{create_or_update::post::CreateOrUpdatePost, CreateOrUpdateType},
 };
-use activitystreams::public;
+use activitystreams_kinds::public;
 use anyhow::anyhow;
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
index 46675442fe77650c5c375f56c6fe0b521a690975..7269078af22caeae0e4cb4628a8a140665955146 100644 (file)
@@ -3,7 +3,7 @@ use crate::{
   objects::{person::ApubPerson, private_message::ApubPrivateMessage},
   protocol::activities::private_message::delete::DeletePrivateMessage,
 };
-use activitystreams::activity::kind::DeleteType;
+use activitystreams_kinds::activity::DeleteType;
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
index fbb8660c34ccc3301948da04f99cb2d02d9138ef..ce3cc49cbc1a3f9e66c6bf01639ae8178c75d320 100644 (file)
@@ -6,7 +6,7 @@ use crate::{
     undo_delete::UndoDeletePrivateMessage,
   },
 };
-use activitystreams::activity::kind::UndoType;
+use activitystreams_kinds::activity::UndoType;
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
index e403a335aa9344bdb9a426463b3a349bf5100cd1..f913ce5f171e7aff698ab301935679bb3eff130d 100644 (file)
@@ -15,7 +15,7 @@ use crate::{
   },
   PostOrComment,
 };
-use activitystreams::{activity::kind::UndoType, public};
+use activitystreams_kinds::{activity::UndoType, public};
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
index 2253b9aa739b289e05601e8b32c0e118cc770c2e..65a9280020853df084ef167f0c27ae372e98a1a6 100644 (file)
@@ -12,7 +12,7 @@ use crate::{
   protocol::activities::voting::vote::{Vote, VoteType},
   PostOrComment,
 };
-use activitystreams::public;
+use activitystreams_kinds::public;
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
index 695f7aca1ff53c6a0a19045fcc626f6690726d00..1b0911ab7f5517538ce3312e30d29deeecd8b0d4 100644 (file)
@@ -4,7 +4,8 @@ use crate::{
   objects::person::ApubPerson,
   protocol::collections::group_moderators::GroupModerators,
 };
-use activitystreams::{chrono::NaiveDateTime, collection::kind::OrderedCollectionType};
+use activitystreams_kinds::collection::OrderedCollectionType;
+use chrono::NaiveDateTime;
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{object_id::ObjectId, traits::ApubObject, verify::verify_domains_match};
 use lemmy_db_schema::{
index 69dfd929f944668ab253cb576bca6f251c44f4c0..de55ffa6e423a12e921ce53b181560dbcb840874 100644 (file)
@@ -8,7 +8,7 @@ use crate::{
     collections::group_outbox::GroupOutbox,
   },
 };
-use activitystreams::collection::kind::OrderedCollectionType;
+use activitystreams_kinds::collection::OrderedCollectionType;
 use chrono::NaiveDateTime;
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
index 55486872ff592b714c038fcebaf683b28a38be50..0a6e220a73ef6a8058014b17bd59c9f22f373ec2 100644 (file)
@@ -1,15 +1,14 @@
-use activitystreams::{base::AnyBase, primitives::OneOrMany};
 use serde::{Deserialize, Serialize};
 
 lazy_static! {
-  static ref CONTEXT: OneOrMany<AnyBase> =
+  static ref CONTEXT: Vec<serde_json::Value> =
     serde_json::from_str(include_str!("../assets/lemmy/context.json")).expect("parse context");
 }
 
-#[derive(Serialize, Deserialize)]
+#[derive(Serialize, Deserialize, Debug)]
 pub(crate) struct WithContext<T> {
   #[serde(rename = "@context")]
-  context: OneOrMany<AnyBase>,
+  context: Vec<serde_json::Value>,
   #[serde(flatten)]
   inner: T,
 }
index e5dc3d935afafcd1374cef63086a6ae30688e68c..08138964c89a6f8f8c89c617c5fb154903a4f4b5 100644 (file)
@@ -2,11 +2,12 @@ use crate::{
   objects::{community::ApubCommunity, person::ApubPerson},
   protocol::objects::{group::Group, person::Person},
 };
-use activitystreams::{chrono::NaiveDateTime, url::Url};
+use chrono::NaiveDateTime;
 use lemmy_apub_lib::traits::{ActorType, ApubObject};
 use lemmy_utils::LemmyError;
 use lemmy_websocket::LemmyContext;
 use serde::Deserialize;
+use url::Url;
 
 #[derive(Clone, Debug)]
 pub enum UserOrCommunity {
index 2cf0e757adfb8fd0d48b5a12887f9f87709991bd..f8de438556fa0189279d3761d59cbe2cadadad7a 100644 (file)
@@ -2,10 +2,7 @@ use crate::{
   fetcher::webfinger::webfinger_resolve_actor,
   objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson},
 };
-use activitystreams::{
-  base::BaseExt,
-  link::{LinkExt, Mention},
-};
+use activitystreams_kinds::link::MentionType;
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{object_id::ObjectId, traits::ActorType};
 use lemmy_db_schema::{
@@ -18,8 +15,17 @@ use lemmy_utils::{
   LemmyError,
 };
 use lemmy_websocket::LemmyContext;
+use serde::{Deserialize, Serialize};
 use url::Url;
 
+#[derive(Clone, Debug, Deserialize, Serialize)]
+pub struct Mention {
+  pub href: Url,
+  name: Option<String>,
+  #[serde(rename = "type")]
+  pub kind: MentionType,
+}
+
 pub struct MentionsAndAddresses {
   pub ccs: Vec<Url>,
   pub tags: Vec<Mention>,
@@ -38,14 +44,15 @@ pub async fn collect_non_local_mentions(
   let mut addressed_ccs: Vec<Url> = vec![community_id.into(), parent_creator.actor_id()];
 
   // Add the mention tag
-  let mut parent_creator_tag = Mention::new();
-  parent_creator_tag
-    .set_href(parent_creator.actor_id.clone().into())
-    .set_name(format!(
+  let parent_creator_tag = Mention {
+    href: parent_creator.actor_id.clone().into(),
+    name: Some(format!(
       "@{}@{}",
       &parent_creator.name,
       &parent_creator.actor_id().domain().expect("has domain")
-    ));
+    )),
+    kind: MentionType::Mention,
+  };
   let mut tags = vec![parent_creator_tag];
 
   // Get the person IDs for any mentions
@@ -64,10 +71,11 @@ pub async fn collect_non_local_mentions(
       let actor_id: ObjectId<ApubPerson> = ObjectId::new(actor_id);
       addressed_ccs.push(actor_id.to_string().parse()?);
 
-      let mut mention_tag = Mention::new();
-      mention_tag
-        .set_href(actor_id.into())
-        .set_name(mention.full_name());
+      let mention_tag = Mention {
+        href: actor_id.into(),
+        name: Some(mention.full_name()),
+        kind: MentionType::Mention,
+      };
       tags.push(mention_tag);
     }
   }
index f15084cc4f53fdf7014a6759f2cd34fe032897ca..007d3def4409cf7b6f4d1f2e9b02efd361447902 100644 (file)
@@ -11,7 +11,7 @@ use crate::{
   },
   PostOrComment,
 };
-use activitystreams::{object::kind::NoteType, public};
+use activitystreams_kinds::{object::NoteType, public};
 use anyhow::anyhow;
 use chrono::NaiveDateTime;
 use html2md::parse_html;
index f37d82d8cd3a539a475edff5f484d69669336751..d8bc837fb3d1d6155be6964e37d8739b98faca47 100644 (file)
@@ -9,7 +9,7 @@ use crate::{
     Source,
   },
 };
-use activitystreams::{actor::kind::GroupType, object::kind::ImageType};
+use activitystreams_kinds::actor::GroupType;
 use chrono::NaiveDateTime;
 use itertools::Itertools;
 use lemmy_api_common::blocking;
@@ -81,14 +81,8 @@ impl ApubObject for ApubCommunity {
       content: bio,
       media_type: MediaTypeMarkdown::Markdown,
     });
-    let icon = self.icon.clone().map(|url| ImageObject {
-      kind: ImageType::Image,
-      url: url.into(),
-    });
-    let image = self.banner.clone().map(|url| ImageObject {
-      kind: ImageType::Image,
-      url: url.into(),
-    });
+    let icon = self.icon.clone().map(ImageObject::new);
+    let image = self.banner.clone().map(ImageObject::new);
 
     let group = Group {
       kind: GroupType::Group,
index e3fcdd2eeb010f308220ae6002ab0d90d1d6637b..422862cbf9e7de4b441698e0db5f8a023e07c6cf 100644 (file)
@@ -11,7 +11,6 @@ use crate::{
     Source,
   },
 };
-use activitystreams::object::kind::ImageType;
 use chrono::NaiveDateTime;
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
@@ -89,14 +88,8 @@ impl ApubObject for ApubPerson {
       content: bio,
       media_type: MediaTypeMarkdown::Markdown,
     });
-    let icon = self.avatar.clone().map(|url| ImageObject {
-      kind: ImageType::Image,
-      url: url.into(),
-    });
-    let image = self.banner.clone().map(|url| ImageObject {
-      kind: ImageType::Image,
-      url: url.into(),
-    });
+    let icon = self.avatar.clone().map(ImageObject::new);
+    let image = self.banner.clone().map(ImageObject::new);
 
     let person = Person {
       kind,
index 44dbe73bd5c1dcf1df96e147b6ea654b5466f949..1d4eddb9ce6bb71acfbe05012739eb925e18d2ce 100644 (file)
@@ -7,10 +7,7 @@ use crate::{
     Source,
   },
 };
-use activitystreams::{
-  object::kind::{ImageType, PageType},
-  public,
-};
+use activitystreams_kinds::{object::PageType, public};
 use chrono::NaiveDateTime;
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
@@ -100,10 +97,7 @@ impl ApubObject for ApubPost {
       content: body,
       media_type: MediaTypeMarkdown::Markdown,
     });
-    let image = self.thumbnail_url.clone().map(|thumb| ImageObject {
-      kind: ImageType::Image,
-      url: thumb.into(),
-    });
+    let image = self.thumbnail_url.clone().map(ImageObject::new);
 
     let page = Page {
       r#type: PageType::Page,
index 75571bea8f07b49b0956d817ef25e4026527352d..0d6edc0a6ba3a943d9aa3f50caaee1dec846b911 100644 (file)
@@ -1,5 +1,5 @@
-use crate::objects::person::ApubPerson;
-use activitystreams::{activity::kind::AddType, unparsed::Unparsed};
+use crate::{objects::person::ApubPerson, protocol::Unparsed};
+use activitystreams_kinds::activity::AddType;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index 2dd094041768c30af3c9f6a5db312281e249a255..11890c680d9ad630a4a996b0bc31fe98827b0b31 100644 (file)
@@ -1,5 +1,9 @@
-use crate::{activity_lists::AnnouncableActivities, objects::community::ApubCommunity};
-use activitystreams::{activity::kind::AnnounceType, unparsed::Unparsed};
+use crate::{
+  activity_lists::AnnouncableActivities,
+  objects::community::ApubCommunity,
+  protocol::Unparsed,
+};
+use activitystreams_kinds::activity::AnnounceType;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index 0b974f697fcef17ff8c6d5a5bc9ca024320019e8..c904fc2186e632b64a2d4ffcc66190389c448a77 100644 (file)
@@ -1,5 +1,8 @@
-use crate::objects::{community::ApubCommunity, person::ApubPerson};
-use activitystreams::{activity::kind::BlockType, unparsed::Unparsed};
+use crate::{
+  objects::{community::ApubCommunity, person::ApubPerson},
+  protocol::Unparsed,
+};
+use activitystreams_kinds::activity::BlockType;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index a7bc81411aa130db02690c56cd1ab0b39ebc3d22..4f1f2be91a6eba23641c307d5255cf2b81997337 100644 (file)
@@ -11,6 +11,7 @@ mod tests {
   use crate::protocol::{
     activities::community::{
       add_mod::AddMod,
+      announce::AnnounceActivity,
       block_user::BlockUserFromCommunity,
       remove_mod::RemoveMod,
       report::Report,
@@ -19,13 +20,10 @@ mod tests {
     },
     tests::test_parse_lemmy_item,
   };
-  use activitystreams::activity::Announce;
-  use serial_test::serial;
 
   #[actix_rt::test]
-  #[serial]
   async fn test_parse_lemmy_community() {
-    test_parse_lemmy_item::<Announce>(
+    test_parse_lemmy_item::<AnnounceActivity>(
       "assets/lemmy/activities/community/announce_create_page.json",
     );
 
index 6e3e5458c14b6b581afd6f90ff77aeab42ac1172..dc456b0b038dc8468015ade9ae2b0bc3550cde68 100644 (file)
@@ -1,5 +1,5 @@
-use crate::objects::person::ApubPerson;
-use activitystreams::{activity::kind::RemoveType, unparsed::Unparsed};
+use crate::{objects::person::ApubPerson, protocol::Unparsed};
+use activitystreams_kinds::activity::RemoveType;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index fbf21ec8d344a90ff04819e4d36e02d1a7a8a594..bf1a84f17be26a6acc7a951b28de41f8ea99d090 100644 (file)
@@ -1,8 +1,9 @@
 use crate::{
   fetcher::post_or_comment::PostOrComment,
   objects::{community::ApubCommunity, person::ApubPerson},
+  protocol::Unparsed,
 };
-use activitystreams::{activity::kind::FlagType, unparsed::Unparsed};
+use activitystreams_kinds::activity::FlagType;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index 538a7e25c51b60bb4ac3f0371ba0f4338f3d62c7..f08e0c3523f0c29ea2e15704a3db3f4349974b39 100644 (file)
@@ -1,8 +1,8 @@
 use crate::{
   objects::person::ApubPerson,
-  protocol::activities::community::block_user::BlockUserFromCommunity,
+  protocol::{activities::community::block_user::BlockUserFromCommunity, Unparsed},
 };
-use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
+use activitystreams_kinds::activity::UndoType;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index 9a831a1f8149b3ac15f01d7f28451fc460eee7ad..9bdcded9a61c0f3fa21396fa8bde6be5a5f03758 100644 (file)
@@ -1,5 +1,8 @@
-use crate::{objects::person::ApubPerson, protocol::objects::group::Group};
-use activitystreams::{activity::kind::UpdateType, unparsed::Unparsed};
+use crate::{
+  objects::person::ApubPerson,
+  protocol::{objects::group::Group, Unparsed},
+};
+use activitystreams_kinds::activity::UpdateType;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index 6e90dedb0de1bb270c08d90d0b6646d2f3501997..deef4c86211e8f62aeb899a114a80a9e75ba617c 100644 (file)
@@ -1,8 +1,8 @@
 use crate::{
+  mentions::Mention,
   objects::person::ApubPerson,
-  protocol::{activities::CreateOrUpdateType, objects::note::Note},
+  protocol::{activities::CreateOrUpdateType, objects::note::Note, Unparsed},
 };
-use activitystreams::{link::Mention, unparsed::Unparsed};
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index f5db71c20e6c8e46876f0bdaf9d35d7b7b4f8e4e..6506c283b4fcbd0c16d9bc906f1fef3417350ed3 100644 (file)
@@ -10,10 +10,8 @@ mod tests {
       tests::test_parse_lemmy_item,
     },
   };
-  use serial_test::serial;
 
   #[actix_rt::test]
-  #[serial]
   async fn test_parse_create_or_update() {
     test_parse_lemmy_item::<CreateOrUpdatePost>(
       "assets/lemmy/activities/create_or_update/create_page.json",
index e64e48408b6ec9a3b7ff637254c2b0d9cb797dbc..db159c8609cabdbd432a1a4f1aa186c1633dd870 100644 (file)
@@ -1,8 +1,7 @@
 use crate::{
   objects::person::ApubPerson,
-  protocol::{activities::CreateOrUpdateType, objects::page::Page},
+  protocol::{activities::CreateOrUpdateType, objects::page::Page, Unparsed},
 };
-use activitystreams::unparsed::Unparsed;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index 26aee276e83b25416b40efdc9f29cf4a494e12cb..49adb6e6514dfc95028cf8d333c287f3acdb8e1b 100644 (file)
@@ -1,5 +1,8 @@
-use crate::{objects::person::ApubPerson, protocol::objects::tombstone::Tombstone};
-use activitystreams::{activity::kind::DeleteType, unparsed::Unparsed};
+use crate::{
+  objects::person::ApubPerson,
+  protocol::{objects::tombstone::Tombstone, Unparsed},
+};
+use activitystreams_kinds::activity::DeleteType;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use serde_with::skip_serializing_none;
index 647c3d50708b4f43486ece45f286115073716052..a4e08fab282d72111fd8f16161c49dc18cedfc82 100644 (file)
@@ -7,10 +7,8 @@ mod tests {
     activities::deletion::{delete::Delete, undo_delete::UndoDelete},
     tests::test_parse_lemmy_item,
   };
-  use serial_test::serial;
 
   #[actix_rt::test]
-  #[serial]
   async fn test_parse_lemmy_deletion() {
     test_parse_lemmy_item::<Delete>("assets/lemmy/activities/deletion/remove_note.json");
     test_parse_lemmy_item::<Delete>("assets/lemmy/activities/deletion/delete_page.json");
index aa851cbc73db30ebdecb5d376ffcdc3b3f560c9e..d760801700e284d187e1e873fdad65b7b1d908a2 100644 (file)
@@ -1,5 +1,8 @@
-use crate::{objects::person::ApubPerson, protocol::activities::deletion::delete::Delete};
-use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
+use crate::{
+  objects::person::ApubPerson,
+  protocol::{activities::deletion::delete::Delete, Unparsed},
+};
+use activitystreams_kinds::activity::UndoType;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index 2d5acb3be18b06fbec0ad9400e3a193bef80c9de..09d3419a1b0e29fdaa8024acaf51034b874b9719 100644 (file)
@@ -1,8 +1,8 @@
 use crate::{
   objects::community::ApubCommunity,
-  protocol::activities::following::follow::FollowCommunity,
+  protocol::{activities::following::follow::FollowCommunity, Unparsed},
 };
-use activitystreams::{activity::kind::AcceptType, unparsed::Unparsed};
+use activitystreams_kinds::activity::AcceptType;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index fe4e4e7b952328091e76b00f3ab60bef6e602392..cc2cc8e0aabe3b8c6e65541ef922009eb053ad54 100644 (file)
@@ -1,5 +1,8 @@
-use crate::objects::{community::ApubCommunity, person::ApubPerson};
-use activitystreams::{activity::kind::FollowType, unparsed::Unparsed};
+use crate::{
+  objects::{community::ApubCommunity, person::ApubPerson},
+  protocol::Unparsed,
+};
+use activitystreams_kinds::activity::FollowType;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index 473dfca35cb5fd2069fc3adf316821dd63b0cc2d..3258dbb7e0b3fe964af58724c900f246b6fdb72e 100644 (file)
@@ -12,10 +12,8 @@ mod tests {
     },
     tests::test_parse_lemmy_item,
   };
-  use serial_test::serial;
 
   #[actix_rt::test]
-  #[serial]
   async fn test_parse_lemmy_accept_follow() {
     test_parse_lemmy_item::<FollowCommunity>("assets/lemmy/activities/following/follow.json");
     test_parse_lemmy_item::<AcceptFollowCommunity>("assets/lemmy/activities/following/accept.json");
index f2feba14b07e4c00dae3e13d67b8ae4392355318..f14e3a48d6c8196fc0a204f3a8d94d6c2b0c636a 100644 (file)
@@ -1,8 +1,8 @@
 use crate::{
   objects::person::ApubPerson,
-  protocol::activities::following::follow::FollowCommunity,
+  protocol::{activities::following::follow::FollowCommunity, Unparsed},
 };
-use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
+use activitystreams_kinds::activity::UndoType;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index 756bfd5e908b59e3d0c19980e6835acbde094676..a319daff5a545285753e2ed87797e508afef67b0 100644 (file)
@@ -1,8 +1,7 @@
 use crate::{
   objects::person::ApubPerson,
-  protocol::{activities::CreateOrUpdateType, objects::chat_message::ChatMessage},
+  protocol::{activities::CreateOrUpdateType, objects::chat_message::ChatMessage, Unparsed},
 };
-use activitystreams::unparsed::Unparsed;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index f9ad29fdefaa92f8b6388a24d664622ab272eeef..1156b0e8e196fb2b8cb8e5ce347f76781766ae0e 100644 (file)
@@ -1,5 +1,8 @@
-use crate::objects::{person::ApubPerson, private_message::ApubPrivateMessage};
-use activitystreams::{activity::kind::DeleteType, unparsed::Unparsed};
+use crate::{
+  objects::{person::ApubPerson, private_message::ApubPrivateMessage},
+  protocol::Unparsed,
+};
+use activitystreams_kinds::activity::DeleteType;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index b54e66c0c21ee5511e3517651a213b2e16e1751e..de074ba692785dc54abe573a2bcda9fb37365125 100644 (file)
@@ -12,10 +12,8 @@ mod tests {
     },
     tests::test_parse_lemmy_item,
   };
-  use serial_test::serial;
 
   #[actix_rt::test]
-  #[serial]
   async fn test_parse_lemmy_private_message() {
     test_parse_lemmy_item::<CreateOrUpdatePrivateMessage>(
       "assets/lemmy/activities/private_message/create.json",
index 951f14d4a9fd71f0a30e0d9b2780047adf1a9242..3ce2607582ffb3a35bcc162b3836fd7c760794e9 100644 (file)
@@ -1,8 +1,8 @@
 use crate::{
   objects::person::ApubPerson,
-  protocol::activities::private_message::delete::DeletePrivateMessage,
+  protocol::{activities::private_message::delete::DeletePrivateMessage, Unparsed},
 };
-use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
+use activitystreams_kinds::activity::UndoType;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index 48e30f0b1c90e3e69b3db23e4104b097d96311bc..b38e7fe3ddb85eef6b8241c6895228498d44e07c 100644 (file)
@@ -7,10 +7,8 @@ mod tests {
     activities::voting::{undo_vote::UndoVote, vote::Vote},
     tests::test_parse_lemmy_item,
   };
-  use serial_test::serial;
 
   #[actix_rt::test]
-  #[serial]
   async fn test_parse_lemmy_voting() {
     test_parse_lemmy_item::<Vote>("assets/lemmy/activities/voting/like_note.json");
     test_parse_lemmy_item::<Vote>("assets/lemmy/activities/voting/dislike_page.json");
index c6c8f0b030a1e6f55ec9aa880b7c94660b21a757..9a1767f2a0793e5c373d61c7e5549ff16e8f4561 100644 (file)
@@ -1,5 +1,8 @@
-use crate::{objects::person::ApubPerson, protocol::activities::voting::vote::Vote};
-use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
+use crate::{
+  objects::person::ApubPerson,
+  protocol::{activities::voting::vote::Vote, Unparsed},
+};
+use activitystreams_kinds::activity::UndoType;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index 977a549dbc58ace61f41bb702ed1bc1f7fa75a02..065e3b31f6d3e40a7017dfa2c110f6ac33527f6a 100644 (file)
@@ -1,5 +1,8 @@
-use crate::{fetcher::post_or_comment::PostOrComment, objects::person::ApubPerson};
-use activitystreams::unparsed::Unparsed;
+use crate::{
+  fetcher::post_or_comment::PostOrComment,
+  objects::person::ApubPerson,
+  protocol::Unparsed,
+};
 use anyhow::anyhow;
 use lemmy_apub_lib::object_id::ObjectId;
 use lemmy_utils::LemmyError;
index 55b92a76cbf0a95eb0d7b0f6a38617a9c96fbc05..032731b739ea21a4191031baea15f0be9261b552 100644 (file)
@@ -1,5 +1,5 @@
 use crate::generate_followers_url;
-use activitystreams::collection::kind::CollectionType;
+use activitystreams_kinds::collection::CollectionType;
 use lemmy_api_common::blocking;
 use lemmy_db_schema::source::community::Community;
 use lemmy_db_views_actor::community_follower_view::CommunityFollowerView;
index 9b8494849f9a91e4355e81f2feecbd73a4fdd0a9..6a72b9551675a295b9b30600c172fd4a8849806f 100644 (file)
@@ -1,5 +1,5 @@
 use crate::objects::person::ApubPerson;
-use activitystreams::collection::kind::OrderedCollectionType;
+use activitystreams_kinds::collection::OrderedCollectionType;
 use lemmy_apub_lib::object_id::ObjectId;
 use serde::{Deserialize, Serialize};
 use url::Url;
index f7c70792b8f7bda4ee26e59cf7c1b6947ecc6ed7..2806d2695630f7eace510cd7b36b9c4686d3e5a3 100644 (file)
@@ -1,5 +1,5 @@
 use crate::protocol::activities::community::announce::AnnounceActivity;
-use activitystreams::collection::kind::OrderedCollectionType;
+use activitystreams_kinds::collection::OrderedCollectionType;
 use serde::{Deserialize, Serialize};
 use url::Url;
 
index 2e2d5c20af51eaf327ca962751dfd865329efe15..214bd6d3c54feba177030cecfb66f0a2c5f617cd 100644 (file)
@@ -14,10 +14,8 @@ mod tests {
     },
     tests::test_parse_lemmy_item,
   };
-  use serial_test::serial;
 
   #[actix_rt::test]
-  #[serial]
   async fn test_parse_lemmy_collections() {
     test_parse_lemmy_item::<GroupFollowers>("assets/lemmy/collections/group_followers.json");
     let outbox = test_parse_lemmy_item::<GroupOutbox>("assets/lemmy/collections/group_outbox.json");
index c8af0173baf1f222c6ee1d88ef0b82d97253a079..e616794c6c75a0b6601e2b0028ad4bdf294d5855 100644 (file)
@@ -1,5 +1,5 @@
 use crate::generate_outbox_url;
-use activitystreams::collection::kind::OrderedCollectionType;
+use activitystreams_kinds::collection::OrderedCollectionType;
 use lemmy_db_schema::source::person::Person;
 use lemmy_utils::LemmyError;
 use serde::{Deserialize, Serialize};
index 37a29f8fa0c8e70d68445bb58311d5a9a131b392..2a4acf2467c490f09627ec76b789db7b8e98e298 100644 (file)
@@ -1,8 +1,10 @@
-use activitystreams::object::kind::ImageType;
+use activitystreams_kinds::object::ImageType;
 use serde::{Deserialize, Serialize};
 use url::Url;
 
 use lemmy_apub_lib::values::MediaTypeMarkdown;
+use lemmy_db_schema::newtypes::DbUrl;
+use std::collections::HashMap;
 
 pub mod activities;
 pub(crate) mod collections;
@@ -19,10 +21,23 @@ pub struct Source {
 #[serde(rename_all = "camelCase")]
 pub struct ImageObject {
   #[serde(rename = "type")]
-  pub(crate) kind: ImageType,
+  kind: ImageType,
   pub(crate) url: Url,
 }
 
+impl ImageObject {
+  pub(crate) fn new(url: DbUrl) -> Self {
+    ImageObject {
+      kind: ImageType::Image,
+      url: url.into(),
+    }
+  }
+}
+
+#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize)]
+#[serde(transparent)]
+pub struct Unparsed(HashMap<String, serde_json::Value>);
+
 #[cfg(test)]
 pub(crate) mod tests {
   use crate::objects::tests::file_to_json_object;
index b86929139f497bc5a3b3f0af5bad26ab8b8c81fc..64499ea33e9f05f729459949453ecf224f7fe590 100644 (file)
@@ -1,11 +1,8 @@
 use crate::{
   objects::{person::ApubPerson, private_message::ApubPrivateMessage},
-  protocol::Source,
-};
-use activitystreams::{
-  chrono::{DateTime, FixedOffset},
-  unparsed::Unparsed,
+  protocol::{Source, Unparsed},
 };
+use chrono::{DateTime, FixedOffset};
 use lemmy_apub_lib::{object_id::ObjectId, values::MediaTypeHtml};
 use serde::{Deserialize, Serialize};
 use serde_with::skip_serializing_none;
index 4dc1c5bd1d8e9d02540b5df1d32bbede4d4b5511..def878599e4f582c42d622e343867f534afdcedf 100644 (file)
@@ -5,9 +5,9 @@ use crate::{
     community_outbox::ApubCommunityOutbox,
   },
   objects::{community::ApubCommunity, get_summary_from_string_or_source},
-  protocol::{objects::Endpoints, ImageObject, Source},
+  protocol::{objects::Endpoints, ImageObject, Source, Unparsed},
 };
-use activitystreams::{actor::kind::GroupType, unparsed::Unparsed};
+use activitystreams_kinds::actor::GroupType;
 use chrono::{DateTime, FixedOffset};
 use lemmy_apub_lib::{object_id::ObjectId, signatures::PublicKey, verify::verify_domains_match};
 use lemmy_db_schema::{naive_now, source::community::CommunityForm};
index f8cc877a70c251a1bf72a925f0710394e6afaa95..bd590d493e78fe8d8d29c0133717b7b5bd37d2b4 100644 (file)
@@ -24,10 +24,8 @@ mod tests {
       tests::test_parse_lemmy_item,
     },
   };
-  use serial_test::serial;
 
   #[actix_rt::test]
-  #[serial]
   async fn test_parse_object() {
     test_parse_lemmy_item::<Person>("assets/lemmy/objects/person.json");
     test_parse_lemmy_item::<Group>("assets/lemmy/objects/group.json");
index 883a1a994fcb5ab9269be498e092c53e9edf4a1e..be21f8f5769184e7ff98c338b4ab612f3bdc4695 100644 (file)
@@ -1,9 +1,10 @@
 use crate::{
   fetcher::post_or_comment::PostOrComment,
+  mentions::Mention,
   objects::{comment::ApubComment, person::ApubPerson, post::ApubPost},
-  protocol::Source,
+  protocol::{Source, Unparsed},
 };
-use activitystreams::{link::Mention, object::kind::NoteType, unparsed::Unparsed};
+use activitystreams_kinds::object::NoteType;
 use chrono::{DateTime, FixedOffset};
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{object_id::ObjectId, values::MediaTypeHtml};
index dd923618e66495027810fab6a0f8d17f7de9591f..2bd5cc6dd416f6cc4ed7c5c861102735f87105e8 100644 (file)
@@ -1,8 +1,8 @@
 use crate::{
   objects::{community::ApubCommunity, person::ApubPerson, post::ApubPost},
-  protocol::{ImageObject, Source},
+  protocol::{ImageObject, Source, Unparsed},
 };
-use activitystreams::{object::kind::PageType, unparsed::Unparsed};
+use activitystreams_kinds::object::PageType;
 use anyhow::anyhow;
 use chrono::{DateTime, FixedOffset};
 use lemmy_apub_lib::{
index e45ea78c7af2f232ffc23fa68384a539bc4ad33d..f66b09aa0fccd4ba5334472a91597382759b59c0 100644 (file)
@@ -1,12 +1,12 @@
 use crate::{
   objects::person::ApubPerson,
-  protocol::{objects::Endpoints, ImageObject, Source},
+  protocol::{objects::Endpoints, ImageObject, Source, Unparsed},
 };
-use activitystreams::{unparsed::Unparsed, url::Url};
 use chrono::{DateTime, FixedOffset};
 use lemmy_apub_lib::{object_id::ObjectId, signatures::PublicKey};
 use serde::{Deserialize, Serialize};
 use serde_with::skip_serializing_none;
+use url::Url;
 
 #[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq)]
 pub enum UserTypes {
index 152066cb55c5e905c7d4730337940946f1c18827..6eb812179d65e03639180ea96839698118be82dd 100644 (file)
@@ -1,4 +1,4 @@
-use activitystreams::object::kind::TombstoneType;
+use activitystreams_kinds::object::TombstoneType;
 use serde::{Deserialize, Serialize};
 use serde_with::skip_serializing_none;
 use url::Url;