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
This commit is contained in:
əlemi 2024-05-29 20:51:30 +02:00
parent f5d0eceaca
commit b72851fbfe
Signed by: alemi
GPG key ID: A4895B84D311642C
13 changed files with 40 additions and 38 deletions

View file

@ -11,7 +11,7 @@ pub async fn faker(ctx: crate::server::Context, count: i64) -> Result<(), sea_or
let key = Rsa::generate(2048).unwrap(); let key = Rsa::generate(2048).unwrap();
let test_user = actor::Model { let test_user = actor::Model {
internal: 42, internal: 42,
id: format!("{domain}/users/test"), id: format!("{domain}/actors/test"),
name: Some("μpub".into()), name: Some("μpub".into()),
domain: clean_domain(domain), domain: clean_domain(domain),
preferred_username: "test".to_string(), 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}")), id: Set(format!("{domain}/objects/{oid}")),
name: Set(None), name: Set(None),
object_type: Set(apb::ObjectType::Note), 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), summary: Set(None),
context: Set(Some(context.clone())), context: Set(Some(context.clone())),
in_reply_to: Set(None), 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), internal: Set(42 + i),
id: Set(format!("{domain}/activities/{aid}")), id: Set(format!("{domain}/activities/{aid}")),
activity_type: Set(apb::ActivityType::Create), 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}"))), object: Set(Some(format!("{domain}/objects/{oid}"))),
target: Set(None), target: Set(None),
published: Set(chrono::Utc::now() - std::time::Duration::from_secs(60*i as u64)), published: Set(chrono::Utc::now() - std::time::Duration::from_secs(60*i as u64)),

View file

@ -45,17 +45,17 @@ impl ActivityPubRouter for Router<crate::server::Context> {
.route("/.well-known/oauth-authorization-server", get(ap::well_known::oauth_authorization_server)) .route("/.well-known/oauth-authorization-server", get(ap::well_known::oauth_authorization_server))
.route("/nodeinfo/:version", get(ap::well_known::nodeinfo)) .route("/nodeinfo/:version", get(ap::well_known::nodeinfo))
// actor routes // actor routes
.route("/users/:id", get(ap::user::view)) .route("/actors/:id", get(ap::user::view))
.route("/users/:id/inbox", post(ap::user::inbox::post)) .route("/actors/:id/inbox", post(ap::user::inbox::post))
.route("/users/:id/inbox", get(ap::user::inbox::get)) .route("/actors/:id/inbox", get(ap::user::inbox::get))
.route("/users/:id/inbox/page", get(ap::user::inbox::page)) .route("/actors/:id/inbox/page", get(ap::user::inbox::page))
.route("/users/:id/outbox", post(ap::user::outbox::post)) .route("/actors/:id/outbox", post(ap::user::outbox::post))
.route("/users/:id/outbox", get(ap::user::outbox::get)) .route("/actors/:id/outbox", get(ap::user::outbox::get))
.route("/users/:id/outbox/page", get(ap::user::outbox::page)) .route("/actors/:id/outbox/page", get(ap::user::outbox::page))
.route("/users/:id/followers", get(ap::user::following::get::<false>)) .route("/actors/:id/followers", get(ap::user::following::get::<false>))
.route("/users/:id/followers/page", get(ap::user::following::page::<false>)) .route("/actors/:id/followers/page", get(ap::user::following::page::<false>))
.route("/users/:id/following", get(ap::user::following::get::<true>)) .route("/actors/:id/following", get(ap::user::following::get::<true>))
.route("/users/:id/following/page", get(ap::user::following::page::<true>)) .route("/actors/:id/following/page", get(ap::user::following::page::<true>))
// activities // activities
.route("/activities/:id", get(ap::activity::view)) .route("/activities/:id", get(ap::activity::view))
// context // context

View file

@ -17,7 +17,7 @@ pub async fn get<const OUTGOING: bool>(
0 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<const OUTGOING: bool>( pub async fn page<const OUTGOING: bool>(
@ -40,7 +40,7 @@ pub async fn page<const OUTGOING: bool>(
.await?; .await?;
crate::server::builders::collection_page( crate::server::builders::collection_page(
&url!(ctx, "/users/{id}/{follow___}/page"), &url!(ctx, "/actors/{id}/{follow___}/page"),
offset, limit, offset, limit,
following.into_iter().map(serde_json::Value::String).collect() following.into_iter().map(serde_json::Value::String).collect()
) )

View file

@ -12,7 +12,7 @@ pub async fn get(
Identity::Anonymous => Err(StatusCode::FORBIDDEN.into()), Identity::Anonymous => Err(StatusCode::FORBIDDEN.into()),
Identity::Remote { .. } => Err(StatusCode::FORBIDDEN.into()), Identity::Remote { .. } => Err(StatusCode::FORBIDDEN.into()),
Identity::Local { id: user, .. } => if ctx.uid(&id) == user { 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 { } else {
Err(StatusCode::FORBIDDEN.into()) Err(StatusCode::FORBIDDEN.into())
}, },
@ -34,7 +34,7 @@ pub async fn page(
} }
crate::server::builders::paginate( crate::server::builders::paginate(
url!(ctx, "/users/{id}/inbox/page"), url!(ctx, "/actors/{id}/inbox/page"),
Condition::any() Condition::any()
.add(model::addressing::Column::Actor.eq(*internal)) .add(model::addressing::Column::Actor.eq(*internal))
.add(model::object::Column::AttributedTo.eq(uid)) .add(model::object::Column::AttributedTo.eq(uid))

View file

@ -6,7 +6,7 @@ pub mod following;
use axum::extract::{Path, Query, State}; 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 crate::{errors::UpubError, model, server::{auth::AuthIdentity, builders::AnyQuery, fetcher::Fetcher, Context}, url};
use super::{jsonld::LD, JsonLD, TryFetch}; use super::{jsonld::LD, JsonLD, TryFetch};
@ -50,10 +50,10 @@ pub async fn view(
// local user // local user
Some((user_model, Some(cfg))) => { Some((user_model, Some(cfg))) => {
let mut user = user_model.ap() let mut user = user_model.ap()
.set_inbox(Node::link(url!(ctx, "/users/{id}/inbox"))) .set_inbox(Node::link(url!(ctx, "/actors/{id}/inbox")))
.set_outbox(Node::link(url!(ctx, "/users/{id}/outbox"))) .set_outbox(Node::link(url!(ctx, "/actors/{id}/outbox")))
.set_following(Node::link(url!(ctx, "/users/{id}/following"))) .set_following(Node::link(url!(ctx, "/actors/{id}/following")))
.set_followers(Node::link(url!(ctx, "/users/{id}/followers"))) .set_followers(Node::link(url!(ctx, "/actors/{id}/followers")))
.set_following_me(following_me) .set_following_me(following_me)
.set_followed_by_me(followed_by_me) .set_followed_by_me(followed_by_me)
.set_endpoints(Node::object( .set_endpoints(Node::object(

View file

@ -8,7 +8,7 @@ pub async fn get(
State(ctx): State<Context>, State(ctx): State<Context>,
Path(id): Path<String>, Path(id): Path<String>,
) -> crate::Result<JsonLD<serde_json::Value>> { ) -> crate::Result<JsonLD<serde_json::Value>> {
crate::server::builders::collection(&url!(ctx, "/users/{id}/outbox"), None) crate::server::builders::collection(&url!(ctx, "/actors/{id}/outbox"), None)
} }
pub async fn page( pub async fn page(
@ -19,7 +19,7 @@ pub async fn page(
) -> crate::Result<JsonLD<serde_json::Value>> { ) -> crate::Result<JsonLD<serde_json::Value>> {
let uid = ctx.uid(&id); let uid = ctx.uid(&id);
crate::server::builders::paginate( crate::server::builders::paginate(
url!(ctx, "/users/{id}/outbox/page"), url!(ctx, "/actors/{id}/outbox/page"),
Condition::all() Condition::all()
.add(auth.filter_condition()) .add(auth.filter_condition())
.add( .add(

View file

@ -93,7 +93,7 @@ impl Addresser for super::Context {
internal: sea_orm::ActiveValue::NotSet, internal: sea_orm::ActiveValue::NotSet,
actor: Set(from.to_string()), actor: Set(from.to_string()),
// TODO we should resolve each user by id and check its inbox because we can't assume // 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), target: Set(inbox),
activity: Set(aid.to_string()), activity: Set(aid.to_string()),
published: Set(chrono::Utc::now()), published: Set(chrono::Utc::now()),

View file

@ -38,7 +38,7 @@ pub fn uri(base: &str, entity: UriClass, id: &str) -> String {
/// decompose local id constructed by uri() fn /// decompose local id constructed by uri() fn
pub fn decompose_id(full_id: &str) -> String { 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("https://", "")
.replace("http://", "") .replace("http://", "")
.split('/') // ['example.org', 'users', 'test', 'followers', 'page?offset=42' ] .split('/') // ['example.org', 'users', 'test', 'followers', 'page?offset=42' ]

View file

@ -19,11 +19,12 @@ pub fn App() -> impl IntoView {
let username = auth.userid.get_untracked() let username = auth.userid.get_untracked()
.map(|x| x.split('/').last().unwrap_or_default().to_string()) .map(|x| x.split('/').last().unwrap_or_default().to_string())
.unwrap_or_default(); .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 server_tl = Timeline::new(format!("{URL_BASE}/inbox/page"));
let local_tl = Timeline::new(format!("{URL_BASE}/outbox/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(); let reply_controls = ReplyControls::default();
provide_context(reply_controls); provide_context(reply_controls);
@ -129,8 +130,9 @@ pub fn App() -> impl IntoView {
<Route path="/web/config" view=move || view! { <ConfigPage setter=set_config /> } /> <Route path="/web/config" view=move || view! { <ConfigPage setter=set_config /> } />
<Route path="/web/config/dev" view=DebugPage /> <Route path="/web/config/dev" view=DebugPage />
<Route path="/web/users/:id" view=move || view! { <UserPage tl=user_tl /> } /> <Route path="/web/actors/:id" view=move || view! { <UserPage tl=user_tl /> } />
<Route path="/web/objects/:id" view=move || view! { <ObjectPage tl=context_tl /> } /> <Route path="/web/objects/:id" view=move || view! { <ObjectPage tl=context_tl /> } />
// <Route path="/web/activities/:id" view=move || view! { <ActivityPage tl=context_tl /> } />
<Route path="/web/search" view=SearchPage /> <Route path="/web/search" view=SearchPage />
<Route path="/web/register" view=RegisterPage /> <Route path="/web/register" view=RegisterPage />

View file

@ -39,6 +39,6 @@ impl AuthToken for Auth {
} }
fn outbox(&self) -> String { fn outbox(&self) -> String {
format!("{URL_BASE}/users/{}/outbox", self.username()) format!("{URL_BASE}/actors/{}/outbox", self.username())
} }
} }

View file

@ -45,7 +45,7 @@ pub fn LoginBox(
userid_tx.set(Some(auth_response.user)); userid_tx.set(Some(auth_response.user));
token_tx.set(Some(auth_response.token)); token_tx.set(Some(auth_response.token));
// reset home feed and point it to our user's inbox // 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); home_tl.more(auth);
// reset server feed: there may be more content now that we're authed // reset server feed: there may be more content now that we're authed
server_tl.reset(format!("{URL_BASE}/inbox/page")); server_tl.reset(format!("{URL_BASE}/inbox/page"));

View file

@ -236,7 +236,7 @@ pub fn LikeButton(
let cc = if private { apb::Node::Empty } else { let cc = if private { apb::Node::Empty } else {
apb::Node::links(vec![ apb::Node::links(vec![
apb::target::PUBLIC.to_string(), 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()) 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; } if !clicked.get() { return; }
set_clicked.set(false); set_clicked.set(false);
let to = apb::Node::links(vec![apb::target::PUBLIC.to_string()]); 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()) let payload = serde_json::Value::Object(serde_json::Map::default())
.set_activity_type(Some(apb::ActivityType::Announce)) .set_activity_type(Some(apb::ActivityType::Announce))
.set_object(apb::Node::link(target.clone())) .set_object(apb::Node::link(target.clone()))

View file

@ -115,7 +115,7 @@ pub fn PostBox(advanced: WriteSignal<bool>) -> impl IntoView {
let mut cc_vec = Vec::new(); let mut cc_vec = Vec::new();
let mut to_vec = Vec::new(); let mut to_vec = Vec::new();
if get_checked(followers_ref) { 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) { if get_checked(public_ref) {
cc_vec.push(apb::target::PUBLIC.to_string()); cc_vec.push(apb::target::PUBLIC.to_string());
@ -240,7 +240,7 @@ pub fn AdvancedPostBox(advanced: WriteSignal<bool>) -> impl IntoView {
<td class="w-66"><input class="w-100" type="text" node_ref=bto_ref title="bto" placeholder="bto" /></td> <td class="w-66"><input class="w-100" type="text" node_ref=bto_ref title="bto" placeholder="bto" /></td>
</tr> </tr>
<tr> <tr>
<td class="w-33"><input class="w-100" type="text" node_ref=cc_ref title="cc" placeholder="cc" value=format!("{URL_BASE}/users/{}/followers", auth.username()) /></td> <td class="w-33"><input class="w-100" type="text" node_ref=cc_ref title="cc" placeholder="cc" value=format!("{URL_BASE}/actors/{}/followers", auth.username()) /></td>
<td class="w-33"><input class="w-100" type="text" node_ref=bcc_ref title="bcc" placeholder="bcc" /></td> <td class="w-33"><input class="w-100" type="text" node_ref=bcc_ref title="bcc" placeholder="bcc" /></td>
</tr> </tr>
</table> </table>
@ -284,7 +284,7 @@ pub fn AdvancedPostBox(advanced: WriteSignal<bool>) -> impl IntoView {
apb::Node::maybe_link(object_id) 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 { match Http::post(&target_url, &payload, auth).await {
Err(e) => set_error.set(Some(e.to_string())), Err(e) => set_error.set(Some(e.to_string())),
Ok(()) => set_error.set(None), Ok(()) => set_error.set(None),