From: Felix Ableitner Date: Fri, 16 Oct 2020 20:44:40 +0000 (+0200) Subject: Swap name and preferredUsername apub fields X-Git-Url: http://these/git/%7Bicon?a=commitdiff_plain;h=06a6bab2c129d683179c89cf04a0903049caec91;p=lemmy.git Swap name and preferredUsername apub fields --- diff --git a/docs/src/contributing_apub_api_outline.md b/docs/src/contributing_apub_api_outline.md index af3eb0f2..acdc2966 100644 --- a/docs/src/contributing_apub_api_outline.md +++ b/docs/src/contributing_apub_api_outline.md @@ -52,8 +52,8 @@ Receives activities from user: `Follow`, `Undo/Follow`, `Create`, `Update`, `Lik "@context": "https://www.w3.org/ns/activitystreams", "id": "https://enterprise.lemmy.ml/c/main", "type": "Group", - "name": "main", - "preferredUsername": "The Main Community", + "preferredUsername": "main", + "name": "The Main Community", "category": { "identifier": "1", "name": "Discussion" @@ -90,8 +90,8 @@ Receives activities from user: `Follow`, `Undo/Follow`, `Create`, `Update`, `Lik | Field Name | Mandatory | Description | |---|---|---| -| `name` | yes | Name of the actor | -| `preferredUsername` | yes | Displayname | +| `preferredUsername` | yes | Name of the actor | +| `name` | yes | Title of the community | | `category` | yes | Hardcoded list of categories, see https://dev.lemmy.ml/api/v1/categories | | `sensitive` | yes | True indicates that all posts in the community are nsfw | | `attributedTo` | yes | First the community creator, then all the remaining moderators | @@ -121,8 +121,8 @@ Sends and receives activities from/to other users: `Create/Note`, `Update/Note`, "@context": "https://www.w3.org/ns/activitystreams", "id": "https://enterprise.lemmy.ml/u/picard", "type": "Person", - "name": "riker", - "preferredUsername": "Jean-Luc Picard", + "preferredUsername": "picard", + "name": "Jean-Luc Picard", "summary": "The user bio", "icon": { "type": "Image", @@ -148,8 +148,8 @@ Sends and receives activities from/to other users: `Create/Note`, `Update/Note`, | Field Name | Mandatory | Description | |---|---|---| -| `name` | yes | Name of the actor | -| `preferredUsername` | no | Displayname | +| `preferredUsername` | yes | Name of the actor | +| `name` | no | The user's displayname | | `summary` | no | User bio | | `icon` | no | The user's avatar, shown next to the username | | `image` | no | The user's banner, shown on top of the profile | diff --git a/lemmy_apub/src/objects/community.rs b/lemmy_apub/src/objects/community.rs index 6a4b1ee5..9efac157 100644 --- a/lemmy_apub/src/objects/community.rs +++ b/lemmy_apub/src/objects/community.rs @@ -51,7 +51,7 @@ impl ToApub for Community { group .set_context(activitystreams::context()) .set_id(Url::parse(&self.actor_id)?) - .set_name(self.name.to_owned()) + .set_name(self.title.to_owned()) .set_published(convert_datetime(self.published)) .set_many_attributed_tos(moderators); @@ -78,7 +78,7 @@ impl ToApub for Community { let mut ap_actor = ApActor::new(self.get_inbox_url()?, group); ap_actor - .set_preferred_username(self.title.to_owned()) + .set_preferred_username(self.name.to_owned()) .set_outbox(self.get_outbox_url()?) .set_followers(self.get_followers_url()?) .set_endpoints(Endpoints { @@ -126,6 +126,11 @@ impl FromApub for CommunityForm { let creator = get_or_fetch_and_upsert_user(creator_uri, context).await?; let name = group + .inner + .preferred_username() + .context(location_info!())? + .to_string(); + let title = group .inner .name() .context(location_info!())? @@ -134,11 +139,6 @@ impl FromApub for CommunityForm { .as_xsd_string() .context(location_info!())? .to_string(); - let title = group - .inner - .preferred_username() - .context(location_info!())? - .to_string(); // TODO: should be parsed as html and tags like