From b72851fbfe1e2a305666b581d560bafb61749a15 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 29 May 2024 20:51:30 +0200 Subject: [PATCH] chore!: /users/ -> /actors/ sorry! this will break federation but better sooner than later, everything is called following its AP name except users??? had to be changed eventually --- src/cli/faker.rs | 6 +++--- src/routes/activitypub/mod.rs | 22 +++++++++++----------- src/routes/activitypub/user/following.rs | 4 ++-- src/routes/activitypub/user/inbox.rs | 4 ++-- src/routes/activitypub/user/mod.rs | 10 +++++----- src/routes/activitypub/user/outbox.rs | 4 ++-- src/server/addresser.rs | 2 +- uriproxy/src/lib.rs | 2 +- web/src/app.rs | 10 ++++++---- web/src/auth.rs | 2 +- web/src/components/login.rs | 2 +- web/src/components/object.rs | 4 ++-- web/src/components/post.rs | 6 +++--- 13 files changed, 40 insertions(+), 38 deletions(-) diff --git a/src/cli/faker.rs b/src/cli/faker.rs index 858c0c09..5def1640 100644 --- a/src/cli/faker.rs +++ b/src/cli/faker.rs @@ -11,7 +11,7 @@ pub async fn faker(ctx: crate::server::Context, count: i64) -> Result<(), sea_or let key = Rsa::generate(2048).unwrap(); let test_user = actor::Model { internal: 42, - id: format!("{domain}/users/test"), + id: format!("{domain}/actors/test"), name: Some("μpub".into()), domain: clean_domain(domain), preferred_username: "test".to_string(), @@ -73,7 +73,7 @@ pub async fn faker(ctx: crate::server::Context, count: i64) -> Result<(), sea_or id: Set(format!("{domain}/objects/{oid}")), name: Set(None), object_type: Set(apb::ObjectType::Note), - attributed_to: Set(Some(format!("{domain}/users/test"))), + attributed_to: Set(Some(format!("{domain}/actors/test"))), summary: Set(None), context: Set(Some(context.clone())), in_reply_to: Set(None), @@ -95,7 +95,7 @@ pub async fn faker(ctx: crate::server::Context, count: i64) -> Result<(), sea_or internal: Set(42 + i), id: Set(format!("{domain}/activities/{aid}")), activity_type: Set(apb::ActivityType::Create), - actor: Set(format!("{domain}/users/test")), + actor: Set(format!("{domain}/actors/test")), object: Set(Some(format!("{domain}/objects/{oid}"))), target: Set(None), published: Set(chrono::Utc::now() - std::time::Duration::from_secs(60*i as u64)), diff --git a/src/routes/activitypub/mod.rs b/src/routes/activitypub/mod.rs index 035e0dc3..808a47e0 100644 --- a/src/routes/activitypub/mod.rs +++ b/src/routes/activitypub/mod.rs @@ -45,17 +45,17 @@ impl ActivityPubRouter for Router { .route("/.well-known/oauth-authorization-server", get(ap::well_known::oauth_authorization_server)) .route("/nodeinfo/:version", get(ap::well_known::nodeinfo)) // actor routes - .route("/users/:id", get(ap::user::view)) - .route("/users/:id/inbox", post(ap::user::inbox::post)) - .route("/users/:id/inbox", get(ap::user::inbox::get)) - .route("/users/:id/inbox/page", get(ap::user::inbox::page)) - .route("/users/:id/outbox", post(ap::user::outbox::post)) - .route("/users/:id/outbox", get(ap::user::outbox::get)) - .route("/users/:id/outbox/page", get(ap::user::outbox::page)) - .route("/users/:id/followers", get(ap::user::following::get::)) - .route("/users/:id/followers/page", get(ap::user::following::page::)) - .route("/users/:id/following", get(ap::user::following::get::)) - .route("/users/:id/following/page", get(ap::user::following::page::)) + .route("/actors/:id", get(ap::user::view)) + .route("/actors/:id/inbox", post(ap::user::inbox::post)) + .route("/actors/:id/inbox", get(ap::user::inbox::get)) + .route("/actors/:id/inbox/page", get(ap::user::inbox::page)) + .route("/actors/:id/outbox", post(ap::user::outbox::post)) + .route("/actors/:id/outbox", get(ap::user::outbox::get)) + .route("/actors/:id/outbox/page", get(ap::user::outbox::page)) + .route("/actors/:id/followers", get(ap::user::following::get::)) + .route("/actors/:id/followers/page", get(ap::user::following::page::)) + .route("/actors/:id/following", get(ap::user::following::get::)) + .route("/actors/:id/following/page", get(ap::user::following::page::)) // activities .route("/activities/:id", get(ap::activity::view)) // context diff --git a/src/routes/activitypub/user/following.rs b/src/routes/activitypub/user/following.rs index d552eb58..ae3bcb3b 100644 --- a/src/routes/activitypub/user/following.rs +++ b/src/routes/activitypub/user/following.rs @@ -17,7 +17,7 @@ pub async fn get( 0 }); - crate::server::builders::collection(&url!(ctx, "/users/{id}/{follow___}"), Some(count)) + crate::server::builders::collection(&url!(ctx, "/actors/{id}/{follow___}"), Some(count)) } pub async fn page( @@ -40,7 +40,7 @@ pub async fn page( .await?; crate::server::builders::collection_page( - &url!(ctx, "/users/{id}/{follow___}/page"), + &url!(ctx, "/actors/{id}/{follow___}/page"), offset, limit, following.into_iter().map(serde_json::Value::String).collect() ) diff --git a/src/routes/activitypub/user/inbox.rs b/src/routes/activitypub/user/inbox.rs index 0049e8af..07e9849d 100644 --- a/src/routes/activitypub/user/inbox.rs +++ b/src/routes/activitypub/user/inbox.rs @@ -12,7 +12,7 @@ pub async fn get( Identity::Anonymous => Err(StatusCode::FORBIDDEN.into()), Identity::Remote { .. } => Err(StatusCode::FORBIDDEN.into()), Identity::Local { id: user, .. } => if ctx.uid(&id) == user { - crate::server::builders::collection(&url!(ctx, "/users/{id}/inbox"), None) + crate::server::builders::collection(&url!(ctx, "/actors/{id}/inbox"), None) } else { Err(StatusCode::FORBIDDEN.into()) }, @@ -34,7 +34,7 @@ pub async fn page( } crate::server::builders::paginate( - url!(ctx, "/users/{id}/inbox/page"), + url!(ctx, "/actors/{id}/inbox/page"), Condition::any() .add(model::addressing::Column::Actor.eq(*internal)) .add(model::object::Column::AttributedTo.eq(uid)) diff --git a/src/routes/activitypub/user/mod.rs b/src/routes/activitypub/user/mod.rs index 7dbd9d7b..7cef50ac 100644 --- a/src/routes/activitypub/user/mod.rs +++ b/src/routes/activitypub/user/mod.rs @@ -6,7 +6,7 @@ pub mod following; use axum::extract::{Path, Query, State}; -use apb::{ActorMut, EndpointsMut, Node}; +use apb::{ActorMut, EndpointsMut, Node, ObjectMut}; use crate::{errors::UpubError, model, server::{auth::AuthIdentity, builders::AnyQuery, fetcher::Fetcher, Context}, url}; use super::{jsonld::LD, JsonLD, TryFetch}; @@ -50,10 +50,10 @@ pub async fn view( // local user Some((user_model, Some(cfg))) => { let mut user = user_model.ap() - .set_inbox(Node::link(url!(ctx, "/users/{id}/inbox"))) - .set_outbox(Node::link(url!(ctx, "/users/{id}/outbox"))) - .set_following(Node::link(url!(ctx, "/users/{id}/following"))) - .set_followers(Node::link(url!(ctx, "/users/{id}/followers"))) + .set_inbox(Node::link(url!(ctx, "/actors/{id}/inbox"))) + .set_outbox(Node::link(url!(ctx, "/actors/{id}/outbox"))) + .set_following(Node::link(url!(ctx, "/actors/{id}/following"))) + .set_followers(Node::link(url!(ctx, "/actors/{id}/followers"))) .set_following_me(following_me) .set_followed_by_me(followed_by_me) .set_endpoints(Node::object( diff --git a/src/routes/activitypub/user/outbox.rs b/src/routes/activitypub/user/outbox.rs index b88b1c91..057d142b 100644 --- a/src/routes/activitypub/user/outbox.rs +++ b/src/routes/activitypub/user/outbox.rs @@ -8,7 +8,7 @@ pub async fn get( State(ctx): State, Path(id): Path, ) -> crate::Result> { - crate::server::builders::collection(&url!(ctx, "/users/{id}/outbox"), None) + crate::server::builders::collection(&url!(ctx, "/actors/{id}/outbox"), None) } pub async fn page( @@ -19,7 +19,7 @@ pub async fn page( ) -> crate::Result> { let uid = ctx.uid(&id); crate::server::builders::paginate( - url!(ctx, "/users/{id}/outbox/page"), + url!(ctx, "/actors/{id}/outbox/page"), Condition::all() .add(auth.filter_condition()) .add( diff --git a/src/server/addresser.rs b/src/server/addresser.rs index cf90c804..80de7b85 100644 --- a/src/server/addresser.rs +++ b/src/server/addresser.rs @@ -93,7 +93,7 @@ impl Addresser for super::Context { internal: sea_orm::ActiveValue::NotSet, actor: Set(from.to_string()), // TODO we should resolve each user by id and check its inbox because we can't assume - // it's /users/{id}/inbox for every software, but oh well it's waaaaay easier now + // it's /actors/{id}/inbox for every software, but oh well it's waaaaay easier now target: Set(inbox), activity: Set(aid.to_string()), published: Set(chrono::Utc::now()), diff --git a/uriproxy/src/lib.rs b/uriproxy/src/lib.rs index 87e76a28..c1ed5375 100644 --- a/uriproxy/src/lib.rs +++ b/uriproxy/src/lib.rs @@ -38,7 +38,7 @@ pub fn uri(base: &str, entity: UriClass, id: &str) -> String { /// decompose local id constructed by uri() fn pub fn decompose_id(full_id: &str) -> String { - full_id // https://example.org/users/test/followers/page?offset=42 + full_id // https://example.org/actors/test/followers/page?offset=42 .replace("https://", "") .replace("http://", "") .split('/') // ['example.org', 'users', 'test', 'followers', 'page?offset=42' ] diff --git a/web/src/app.rs b/web/src/app.rs index f324ad51..d7ed90a1 100644 --- a/web/src/app.rs +++ b/web/src/app.rs @@ -19,11 +19,12 @@ pub fn App() -> impl IntoView { let username = auth.userid.get_untracked() .map(|x| x.split('/').last().unwrap_or_default().to_string()) .unwrap_or_default(); - let home_tl = Timeline::new(format!("{URL_BASE}/users/{username}/inbox/page")); + let home_tl = Timeline::new(format!("{URL_BASE}/actors/{username}/inbox/page")); + let user_tl = Timeline::new(format!("{URL_BASE}/actors/{username}/outbox/page")); let server_tl = Timeline::new(format!("{URL_BASE}/inbox/page")); let local_tl = Timeline::new(format!("{URL_BASE}/outbox/page")); - let user_tl = Timeline::new(format!("{URL_BASE}/users/{username}/outbox/page")); - let context_tl = Timeline::new(format!("{URL_BASE}/outbox/page")); + + let context_tl = Timeline::new(format!("{URL_BASE}/outbox/page")); // TODO ehhh let reply_controls = ReplyControls::default(); provide_context(reply_controls); @@ -129,8 +130,9 @@ pub fn App() -> impl IntoView { } /> - } /> + } /> } /> + // } /> diff --git a/web/src/auth.rs b/web/src/auth.rs index a7dd7703..519b2cea 100644 --- a/web/src/auth.rs +++ b/web/src/auth.rs @@ -39,6 +39,6 @@ impl AuthToken for Auth { } fn outbox(&self) -> String { - format!("{URL_BASE}/users/{}/outbox", self.username()) + format!("{URL_BASE}/actors/{}/outbox", self.username()) } } diff --git a/web/src/components/login.rs b/web/src/components/login.rs index 05805fa7..7c2f01ab 100644 --- a/web/src/components/login.rs +++ b/web/src/components/login.rs @@ -45,7 +45,7 @@ pub fn LoginBox( userid_tx.set(Some(auth_response.user)); token_tx.set(Some(auth_response.token)); // reset home feed and point it to our user's inbox - home_tl.reset(format!("{URL_BASE}/users/{}/inbox/page", username)); + home_tl.reset(format!("{URL_BASE}/actors/{}/inbox/page", username)); home_tl.more(auth); // reset server feed: there may be more content now that we're authed server_tl.reset(format!("{URL_BASE}/inbox/page")); diff --git a/web/src/components/object.rs b/web/src/components/object.rs index 169a4822..e108aeb1 100644 --- a/web/src/components/object.rs +++ b/web/src/components/object.rs @@ -236,7 +236,7 @@ pub fn LikeButton( let cc = if private { apb::Node::Empty } else { apb::Node::links(vec![ apb::target::PUBLIC.to_string(), - format!("{URL_BASE}/users/{}/followers", auth.username()) + format!("{URL_BASE}/actors/{}/followers", auth.username()) ]) }; let payload = serde_json::Value::Object(serde_json::Map::default()) @@ -312,7 +312,7 @@ pub fn RepostButton(n: u64, target: String) -> impl IntoView { if !clicked.get() { return; } set_clicked.set(false); let to = apb::Node::links(vec![apb::target::PUBLIC.to_string()]); - let cc = apb::Node::links(vec![format!("{URL_BASE}/users/{}/followers", auth.username())]); + let cc = apb::Node::links(vec![format!("{URL_BASE}/actors/{}/followers", auth.username())]); let payload = serde_json::Value::Object(serde_json::Map::default()) .set_activity_type(Some(apb::ActivityType::Announce)) .set_object(apb::Node::link(target.clone())) diff --git a/web/src/components/post.rs b/web/src/components/post.rs index d6d89fea..55de976b 100644 --- a/web/src/components/post.rs +++ b/web/src/components/post.rs @@ -115,7 +115,7 @@ pub fn PostBox(advanced: WriteSignal) -> impl IntoView { let mut cc_vec = Vec::new(); let mut to_vec = Vec::new(); if get_checked(followers_ref) { - cc_vec.push(format!("{URL_BASE}/users/{}/followers", auth.username())); + cc_vec.push(format!("{URL_BASE}/actors/{}/followers", auth.username())); } if get_checked(public_ref) { cc_vec.push(apb::target::PUBLIC.to_string()); @@ -240,7 +240,7 @@ pub fn AdvancedPostBox(advanced: WriteSignal) -> impl IntoView { - + @@ -284,7 +284,7 @@ pub fn AdvancedPostBox(advanced: WriteSignal) -> impl IntoView { apb::Node::maybe_link(object_id) } ); - let target_url = format!("{URL_BASE}/users/{}/outbox", auth.username()); + let target_url = format!("{URL_BASE}/actors/{}/outbox", auth.username()); match Http::post(&target_url, &payload, auth).await { Err(e) => set_error.set(Some(e.to_string())), Ok(()) => set_error.set(None),