Merge pull request #1209 from LemmyNet/fix-actor-name-confusion
Swap name and preferredUsername apub fields
This commit is contained in:
commit
18b3eab909
3 changed files with 29 additions and 27 deletions
|
@ -52,8 +52,8 @@ Receives activities from user: `Follow`, `Undo/Follow`, `Create`, `Update`, `Lik
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
"id": "https://enterprise.lemmy.ml/c/main",
|
"id": "https://enterprise.lemmy.ml/c/main",
|
||||||
"type": "Group",
|
"type": "Group",
|
||||||
"name": "main",
|
"preferredUsername": "main",
|
||||||
"preferredUsername": "The Main Community",
|
"name": "The Main Community",
|
||||||
"category": {
|
"category": {
|
||||||
"identifier": "1",
|
"identifier": "1",
|
||||||
"name": "Discussion"
|
"name": "Discussion"
|
||||||
|
@ -90,8 +90,8 @@ Receives activities from user: `Follow`, `Undo/Follow`, `Create`, `Update`, `Lik
|
||||||
|
|
||||||
| Field Name | Mandatory | Description |
|
| Field Name | Mandatory | Description |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `name` | yes | Name of the actor |
|
| `preferredUsername` | yes | Name of the actor |
|
||||||
| `preferredUsername` | yes | Displayname |
|
| `name` | yes | Title of the community |
|
||||||
| `category` | yes | Hardcoded list of categories, see https://dev.lemmy.ml/api/v1/categories |
|
| `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 |
|
| `sensitive` | yes | True indicates that all posts in the community are nsfw |
|
||||||
| `attributedTo` | yes | First the community creator, then all the remaining moderators |
|
| `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",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
"id": "https://enterprise.lemmy.ml/u/picard",
|
"id": "https://enterprise.lemmy.ml/u/picard",
|
||||||
"type": "Person",
|
"type": "Person",
|
||||||
"name": "riker",
|
"preferredUsername": "picard",
|
||||||
"preferredUsername": "Jean-Luc Picard",
|
"name": "Jean-Luc Picard",
|
||||||
"summary": "The user bio",
|
"summary": "The user bio",
|
||||||
"icon": {
|
"icon": {
|
||||||
"type": "Image",
|
"type": "Image",
|
||||||
|
@ -148,8 +148,8 @@ Sends and receives activities from/to other users: `Create/Note`, `Update/Note`,
|
||||||
|
|
||||||
| Field Name | Mandatory | Description |
|
| Field Name | Mandatory | Description |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `name` | yes | Name of the actor |
|
| `preferredUsername` | yes | Name of the actor |
|
||||||
| `preferredUsername` | no | Displayname |
|
| `name` | no | The user's displayname |
|
||||||
| `summary` | no | User bio |
|
| `summary` | no | User bio |
|
||||||
| `icon` | no | The user's avatar, shown next to the username |
|
| `icon` | no | The user's avatar, shown next to the username |
|
||||||
| `image` | no | The user's banner, shown on top of the profile |
|
| `image` | no | The user's banner, shown on top of the profile |
|
||||||
|
|
|
@ -50,7 +50,7 @@ impl ToApub for Community {
|
||||||
group
|
group
|
||||||
.set_context(activitystreams::context())
|
.set_context(activitystreams::context())
|
||||||
.set_id(Url::parse(&self.actor_id)?)
|
.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_published(convert_datetime(self.published))
|
||||||
.set_many_attributed_tos(moderators);
|
.set_many_attributed_tos(moderators);
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ impl ToApub for Community {
|
||||||
|
|
||||||
let mut ap_actor = ApActor::new(self.get_inbox_url()?, group);
|
let mut ap_actor = ApActor::new(self.get_inbox_url()?, group);
|
||||||
ap_actor
|
ap_actor
|
||||||
.set_preferred_username(self.title.to_owned())
|
.set_preferred_username(self.name.to_owned())
|
||||||
.set_outbox(self.get_outbox_url()?)
|
.set_outbox(self.get_outbox_url()?)
|
||||||
.set_followers(self.get_followers_url()?)
|
.set_followers(self.get_followers_url()?)
|
||||||
.set_endpoints(Endpoints {
|
.set_endpoints(Endpoints {
|
||||||
|
@ -124,6 +124,11 @@ impl FromApub for CommunityForm {
|
||||||
|
|
||||||
let creator = get_or_fetch_and_upsert_user(creator_uri, context).await?;
|
let creator = get_or_fetch_and_upsert_user(creator_uri, context).await?;
|
||||||
let name = group
|
let name = group
|
||||||
|
.inner
|
||||||
|
.preferred_username()
|
||||||
|
.context(location_info!())?
|
||||||
|
.to_string();
|
||||||
|
let title = group
|
||||||
.inner
|
.inner
|
||||||
.name()
|
.name()
|
||||||
.context(location_info!())?
|
.context(location_info!())?
|
||||||
|
@ -132,11 +137,6 @@ impl FromApub for CommunityForm {
|
||||||
.as_xsd_string()
|
.as_xsd_string()
|
||||||
.context(location_info!())?
|
.context(location_info!())?
|
||||||
.to_string();
|
.to_string();
|
||||||
let title = group
|
|
||||||
.inner
|
|
||||||
.preferred_username()
|
|
||||||
.context(location_info!())?
|
|
||||||
.to_string();
|
|
||||||
// TODO: should be parsed as html and tags like <script> removed (or use markdown source)
|
// TODO: should be parsed as html and tags like <script> removed (or use markdown source)
|
||||||
// -> same for post.content etc
|
// -> same for post.content etc
|
||||||
let description = group
|
let description = group
|
||||||
|
|
|
@ -28,7 +28,6 @@ impl ToApub for User_ {
|
||||||
person
|
person
|
||||||
.set_context(activitystreams::context())
|
.set_context(activitystreams::context())
|
||||||
.set_id(Url::parse(&self.actor_id)?)
|
.set_id(Url::parse(&self.actor_id)?)
|
||||||
.set_name(self.name.to_owned())
|
|
||||||
.set_published(convert_datetime(self.published));
|
.set_published(convert_datetime(self.published));
|
||||||
|
|
||||||
if let Some(u) = self.updated {
|
if let Some(u) = self.updated {
|
||||||
|
@ -51,16 +50,17 @@ impl ToApub for User_ {
|
||||||
person.set_summary(bio.to_owned());
|
person.set_summary(bio.to_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(i) = self.preferred_username.to_owned() {
|
||||||
|
person.set_name(i);
|
||||||
|
}
|
||||||
|
|
||||||
let mut ap_actor = ApActor::new(self.get_inbox_url()?, person);
|
let mut ap_actor = ApActor::new(self.get_inbox_url()?, person);
|
||||||
|
ap_actor.set_preferred_username(self.name.to_owned());
|
||||||
ap_actor.set_endpoints(Endpoints {
|
ap_actor.set_endpoints(Endpoints {
|
||||||
shared_inbox: Some(self.get_shared_inbox_url()?),
|
shared_inbox: Some(self.get_shared_inbox_url()?),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(i) = &self.preferred_username {
|
|
||||||
ap_actor.set_preferred_username(i.to_owned());
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Ext1::new(ap_actor, self.get_public_key_ext()?))
|
Ok(Ext1::new(ap_actor, self.get_public_key_ext()?))
|
||||||
}
|
}
|
||||||
fn to_tombstone(&self) -> Result<Tombstone, LemmyError> {
|
fn to_tombstone(&self) -> Result<Tombstone, LemmyError> {
|
||||||
|
@ -102,15 +102,17 @@ impl FromApub for UserForm {
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let name = person
|
let name: String = person
|
||||||
.name()
|
.inner
|
||||||
.context(location_info!())?
|
.preferred_username()
|
||||||
.one()
|
|
||||||
.context(location_info!())?
|
|
||||||
.as_xsd_string()
|
|
||||||
.context(location_info!())?
|
.context(location_info!())?
|
||||||
.to_string();
|
.to_string();
|
||||||
let preferred_username = person.inner.preferred_username().map(|u| u.to_string());
|
let preferred_username: Option<String> = person
|
||||||
|
.name()
|
||||||
|
.map(|n| n.one())
|
||||||
|
.flatten()
|
||||||
|
.map(|n| n.to_owned().xsd_string())
|
||||||
|
.flatten();
|
||||||
|
|
||||||
// TODO a limit check (like the API does) might need to be done
|
// TODO a limit check (like the API does) might need to be done
|
||||||
// here when we federate to other platforms. Same for preferred_username
|
// here when we federate to other platforms. Same for preferred_username
|
||||||
|
|
Loading…
Reference in a new issue