fix(ap): visibility-aware addressing — correct to/cc outbound, parse inbound to/cc
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 9m25s
test / unit (pull_request) Successful in 16m39s
test / integration (pull_request) Failing after 17m35s
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 9m25s
test / unit (pull_request) Successful in 16m39s
test / integration (pull_request) Failing after 17m35s
This commit is contained in:
@@ -36,6 +36,23 @@ fn thought_note_json(
|
||||
base_url: &str,
|
||||
) -> anyhow::Result<(url::Url, serde_json::Value)> {
|
||||
let ap_id = url::Url::parse(&format!("{}/thoughts/{}", base_url, thought.id))?;
|
||||
|
||||
// Build to/cc based on visibility per AP spec.
|
||||
let (to, cc) = match thought.visibility {
|
||||
domain::models::thought::Visibility::Public => (
|
||||
vec![crate::urls::AS_PUBLIC.to_string()],
|
||||
vec![local_actor.followers_url.to_string()],
|
||||
),
|
||||
domain::models::thought::Visibility::Unlisted => (
|
||||
vec![local_actor.followers_url.to_string()],
|
||||
vec![crate::urls::AS_PUBLIC.to_string()],
|
||||
),
|
||||
domain::models::thought::Visibility::Followers => {
|
||||
(vec![local_actor.followers_url.to_string()], vec![])
|
||||
}
|
||||
domain::models::thought::Visibility::Direct => (vec![], vec![]),
|
||||
};
|
||||
|
||||
let mut note = serde_json::json!({
|
||||
"type": "Note",
|
||||
"id": ap_id.to_string(),
|
||||
@@ -43,8 +60,8 @@ fn thought_note_json(
|
||||
"attributedTo": local_actor.ap_id.to_string(),
|
||||
"content": thought.content.as_str(),
|
||||
"published": thought.created_at.to_rfc3339(),
|
||||
"to": [crate::urls::AS_PUBLIC],
|
||||
"cc": [local_actor.followers_url.to_string()],
|
||||
"to": to,
|
||||
"cc": cc,
|
||||
"sensitive": thought.sensitive,
|
||||
});
|
||||
if let Some(ref cw) = thought.content_warning {
|
||||
|
||||
Reference in New Issue
Block a user