From b97879e3f0e51a7270336efddfc6b20fd5d258a3 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Wed, 4 Nov 2020 18:04:47 +0100 Subject: [PATCH] Add missing docs for community activities (fixes #1250) I also noticed that community delete was sending the full community json, so I changed that to send the ID instead. --- docs/src/contributing_apub_api_outline.md | 50 +++++++++++++++++++++ lemmy_apub/src/activities/send/community.rs | 9 +--- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/docs/src/contributing_apub_api_outline.md b/docs/src/contributing_apub_api_outline.md index 0556e484..558f92fc 100644 --- a/docs/src/contributing_apub_api_outline.md +++ b/docs/src/contributing_apub_api_outline.md @@ -559,6 +559,56 @@ Sent to: User |---|---|---| | `object` | yes | Any `Create`, `Update`, `Like`, `Dislike`, `Delete` `Remove` or `Undo` activity as described above | +### Remove or Delete Community + +```json +{ + "@context": "https://www.w3.org/ns/activitystreams", + "id": "http://ds9.lemmy.ml/activities/remove/e4ca7688-af9d-48b7-864f-765e7f9f3591", + "type": "Remove", + "actor": "http://ds9.lemmy.ml/u/picard", + "cc": [ + "http://ds9.lemmy.ml/c/some_community/followers" + ], + "to": "https://www.w3.org/ns/activitystreams#Public", + "object": "http://ds9.lemmy.ml/c/some_community" +} +``` + +| Field Name | Mandatory | Description | +|---|---|---| +| `type` | yes | Either `Remove` or `Delete` | + +### Restore Removed or Deleted Community + +```json +{ + "@context": "https://www.w3.org/ns/activitystreams", + "id": "http://ds9.lemmy.ml/activities/like/0703668c-8b09-4a85-aa7a-f93621936901", + "type": "Undo", + "actor": "http://ds9.lemmy.ml/u/lemmy_alpha", + "to": "https://www.w3.org/ns/activitystreams#Public", + "cc": [ + "http://ds9.lemmy.ml/c/testcom/followers" + ], + "object": { + "@context": "https://www.w3.org/ns/activitystreams", + "id": "http://ds9.lemmy.ml/activities/remove/1062b5e0-07e8-44fc-868c-854209935bdd", + "type": "Remove", + "to": "https://www.w3.org/ns/activitystreams#Public", + "cc": [ + "http://ds9.lemmy.ml/c/testcom/followers" + ], + "object": "http://ds9.lemmy.ml/c/testcom", + "actor": "http://ds9.lemmy.ml/u/lemmy_alpha" + } +} + +``` +| Field Name | Mandatory | Description | +|---|---|---| +| `object.type` | yes | Either `Remove` or `Delete` | + ### Create or Update Private message Creates a new private message between two users. diff --git a/lemmy_apub/src/activities/send/community.rs b/lemmy_apub/src/activities/send/community.rs index 446ce6f3..0c1c2bfd 100644 --- a/lemmy_apub/src/activities/send/community.rs +++ b/lemmy_apub/src/activities/send/community.rs @@ -4,7 +4,6 @@ use crate::{ check_is_apub_id_valid, fetcher::get_or_fetch_and_upsert_user, ActorType, - ToApub, }; use activitystreams::{ activity::{ @@ -86,9 +85,7 @@ impl ActorType for Community { /// If the creator of a community deletes the community, send this to all followers. async fn send_delete(&self, creator: &User_, context: &LemmyContext) -> Result<(), LemmyError> { - let group = self.to_apub(context.pool()).await?; - - let mut delete = Delete::new(creator.actor_id.to_owned(), group.into_any_base()?); + let mut delete = Delete::new(creator.actor_id.to_owned(), self.actor_id()?); delete .set_context(activitystreams::context()) .set_id(generate_activity_id(DeleteType::Delete)?) @@ -105,9 +102,7 @@ impl ActorType for Community { creator: &User_, context: &LemmyContext, ) -> Result<(), LemmyError> { - let group = self.to_apub(context.pool()).await?; - - let mut delete = Delete::new(creator.actor_id.to_owned(), group.into_any_base()?); + let mut delete = Delete::new(creator.actor_id.to_owned(), self.actor_id()?); delete .set_context(activitystreams::context()) .set_id(generate_activity_id(DeleteType::Delete)?) -- 2.40.1