mirror of https://github.com/LemmyNet/lemmy.git
Federate group moderators using attributedTo field (#2588)
* Federate group moderators using attributedTo field * fix tests Co-authored-by: Dessalines <dessalines@users.noreply.github.com>federation-audience
parent
96a2bec691
commit
41d4852efc
|
@ -20,6 +20,7 @@
|
||||||
"inbox": "https://enterprise.lemmy.ml/c/tenforward/inbox",
|
"inbox": "https://enterprise.lemmy.ml/c/tenforward/inbox",
|
||||||
"followers": "https://enterprise.lemmy.ml/c/tenforward/followers",
|
"followers": "https://enterprise.lemmy.ml/c/tenforward/followers",
|
||||||
"moderators": "https://enterprise.lemmy.ml/c/tenforward/moderators",
|
"moderators": "https://enterprise.lemmy.ml/c/tenforward/moderators",
|
||||||
|
"attributedTo": "https://enterprise.lemmy.ml/c/tenforward/moderators",
|
||||||
"postingRestrictedToMods": false,
|
"postingRestrictedToMods": false,
|
||||||
"endpoints": {
|
"endpoints": {
|
||||||
"sharedInbox": "https://enterprise.lemmy.ml/inbox"
|
"sharedInbox": "https://enterprise.lemmy.ml/inbox"
|
||||||
|
|
|
@ -89,6 +89,9 @@ impl ApubObject for ApubCommunity {
|
||||||
let community_id = self.id;
|
let community_id = self.id;
|
||||||
let langs = CommunityLanguage::read(data.pool(), community_id).await?;
|
let langs = CommunityLanguage::read(data.pool(), community_id).await?;
|
||||||
let language = LanguageTag::new_multiple(langs, data.pool()).await?;
|
let language = LanguageTag::new_multiple(langs, data.pool()).await?;
|
||||||
|
let attributed_to = Some(ObjectId::<ApubCommunityModerators>::new(
|
||||||
|
generate_moderators_url(&self.actor_id)?,
|
||||||
|
));
|
||||||
|
|
||||||
let group = Group {
|
let group = Group {
|
||||||
kind: GroupType::Group,
|
kind: GroupType::Group,
|
||||||
|
@ -100,9 +103,7 @@ impl ApubObject for ApubCommunity {
|
||||||
icon: self.icon.clone().map(ImageObject::new),
|
icon: self.icon.clone().map(ImageObject::new),
|
||||||
image: self.banner.clone().map(ImageObject::new),
|
image: self.banner.clone().map(ImageObject::new),
|
||||||
sensitive: Some(self.nsfw),
|
sensitive: Some(self.nsfw),
|
||||||
moderators: Some(ObjectId::<ApubCommunityModerators>::new(
|
moderators: attributed_to.clone(),
|
||||||
generate_moderators_url(&self.actor_id)?,
|
|
||||||
)),
|
|
||||||
inbox: self.inbox_url.clone().into(),
|
inbox: self.inbox_url.clone().into(),
|
||||||
outbox: ObjectId::new(generate_outbox_url(&self.actor_id)?),
|
outbox: ObjectId::new(generate_outbox_url(&self.actor_id)?),
|
||||||
followers: self.followers_url.clone().into(),
|
followers: self.followers_url.clone().into(),
|
||||||
|
@ -114,6 +115,7 @@ impl ApubObject for ApubCommunity {
|
||||||
published: Some(convert_datetime(self.published)),
|
published: Some(convert_datetime(self.published)),
|
||||||
updated: self.updated.map(convert_datetime),
|
updated: self.updated.map(convert_datetime),
|
||||||
posting_restricted_to_mods: Some(self.posting_restricted_to_mods),
|
posting_restricted_to_mods: Some(self.posting_restricted_to_mods),
|
||||||
|
attributed_to,
|
||||||
};
|
};
|
||||||
Ok(group)
|
Ok(group)
|
||||||
}
|
}
|
||||||
|
@ -156,7 +158,7 @@ impl ApubObject for ApubCommunity {
|
||||||
.map_err(|e| debug!("{}", e))
|
.map_err(|e| debug!("{}", e))
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
if let Some(moderators) = &group.moderators {
|
if let Some(moderators) = group.attributed_to.or(group.moderators) {
|
||||||
moderators
|
moderators
|
||||||
.dereference(&outbox_data, local_instance(context).await, request_counter)
|
.dereference(&outbox_data, local_instance(context).await, request_counter)
|
||||||
.await
|
.await
|
||||||
|
@ -240,6 +242,7 @@ pub(crate) mod tests {
|
||||||
let mut json: Group = file_to_json_object("assets/lemmy/objects/group.json").unwrap();
|
let mut json: Group = file_to_json_object("assets/lemmy/objects/group.json").unwrap();
|
||||||
// change these links so they dont fetch over the network
|
// change these links so they dont fetch over the network
|
||||||
json.moderators = None;
|
json.moderators = None;
|
||||||
|
json.attributed_to = None;
|
||||||
json.outbox =
|
json.outbox =
|
||||||
ObjectId::new(Url::parse("https://enterprise.lemmy.ml/c/tenforward/not_outbox").unwrap());
|
ObjectId::new(Url::parse("https://enterprise.lemmy.ml/c/tenforward/not_outbox").unwrap());
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,10 @@ pub struct Group {
|
||||||
pub(crate) image: Option<ImageObject>,
|
pub(crate) image: Option<ImageObject>,
|
||||||
// lemmy extension
|
// lemmy extension
|
||||||
pub(crate) sensitive: Option<bool>,
|
pub(crate) sensitive: Option<bool>,
|
||||||
// lemmy extension
|
// deprecated, use attributed_to instead
|
||||||
pub(crate) moderators: Option<ObjectId<ApubCommunityModerators>>,
|
pub(crate) moderators: Option<ObjectId<ApubCommunityModerators>>,
|
||||||
|
#[serde(deserialize_with = "deserialize_skip_error", default)]
|
||||||
|
pub(crate) attributed_to: Option<ObjectId<ApubCommunityModerators>>,
|
||||||
// lemmy extension
|
// lemmy extension
|
||||||
pub(crate) posting_restricted_to_mods: Option<bool>,
|
pub(crate) posting_restricted_to_mods: Option<bool>,
|
||||||
pub(crate) outbox: ObjectId<ApubCommunityOutbox>,
|
pub(crate) outbox: ObjectId<ApubCommunityOutbox>,
|
||||||
|
|
Loading…
Reference in New Issue