diff --git a/src/server/context.rs b/src/server/context.rs index 5fa6bd7..d34da73 100644 --- a/src/server/context.rs +++ b/src/server/context.rs @@ -111,7 +111,7 @@ impl Context { /// get full user id uri pub fn uid(&self, id: &str) -> String { - uriproxy::uri(self.base(), UriClass::User, id) + uriproxy::uri(self.base(), UriClass::Actor, id) } /// get full object id uri diff --git a/uriproxy/src/lib.rs b/uriproxy/src/lib.rs index c1ed537..cd807f7 100644 --- a/uriproxy/src/lib.rs +++ b/uriproxy/src/lib.rs @@ -2,7 +2,7 @@ use base64::Engine; #[derive(Clone, Copy)] pub enum UriClass { - User, + Actor, Object, Activity, Context, @@ -11,7 +11,7 @@ pub enum UriClass { impl AsRef for UriClass { fn as_ref(&self) -> &str { match self { - Self::User => "users", + Self::Actor => "actors", Self::Object => "objects", Self::Activity => "activities", Self::Context => "context", @@ -41,7 +41,7 @@ pub fn decompose_id(full_id: &str) -> String { full_id // https://example.org/actors/test/followers/page?offset=42 .replace("https://", "") .replace("http://", "") - .split('/') // ['example.org', 'users', 'test', 'followers', 'page?offset=42' ] + .split('/') // ['example.org', 'actors', 'test', 'followers', 'page?offset=42' ] .nth(2) // 'test' .unwrap_or("") .to_string() diff --git a/web/src/components/activity.rs b/web/src/components/activity.rs index 6055ef1..406c97c 100644 --- a/web/src/components/activity.rs +++ b/web/src/components/activity.rs @@ -14,7 +14,7 @@ pub fn ActivityLine(activity: crate::Object) -> impl IntoView { let actor = CACHE.get_or(&actor_id, serde_json::Value::String(actor_id.clone()).into()); let kind = activity.activity_type().unwrap_or(apb::ActivityType::Activity); let href = match kind { - apb::ActivityType::Follow => Uri::web(U::User, &object_id), + apb::ActivityType::Follow => Uri::web(U::Actor, &object_id), // TODO for update check what's being updated _ => Uri::web(U::Object, &object_id), }; diff --git a/web/src/components/login.rs b/web/src/components/login.rs index 7c2f01a..50e18d6 100644 --- a/web/src/components/login.rs +++ b/web/src/components/login.rs @@ -14,7 +14,7 @@ pub fn LoginBox( view! {
- "hi "{move || auth.username() } + "hi "{move || auth.username() } ) -> impl IntoView { mentions.get() .map(|x| x.into_iter().map(|u| match CACHE.get(&u) { Some(u) => view! { "📨" }.into_view(), - None => view! { "📨"{u} }.into_view(), + None => view! { "📨"{u} }.into_view(), }) .collect_view()) } diff --git a/web/src/components/timeline.rs b/web/src/components/timeline.rs index b5e1b50..791558c 100644 --- a/web/src/components/timeline.rs +++ b/web/src/components/timeline.rs @@ -211,7 +211,7 @@ async fn process_activities(activities: Vec, auth: Auth) -> V if let Some(object_id) = activity.object().id() { if !gonna_fetch.contains(&object_id) { let fetch_kind = match activity_type { - apb::ActivityType::Follow => U::User, + apb::ActivityType::Follow => U::Actor, _ => U::Object, }; gonna_fetch.insert(object_id.clone()); @@ -235,20 +235,20 @@ async fn process_activities(activities: Vec, auth: Auth) -> V if let Some(uid) = activity.attributed_to().id() { if CACHE.get(&uid).is_none() && !gonna_fetch.contains(&uid) { gonna_fetch.insert(uid.clone()); - sub_tasks.push(Box::pin(fetch_and_update(U::User, uid, auth))); + sub_tasks.push(Box::pin(fetch_and_update(U::Actor, uid, auth))); } } if let Some(uid) = activity.actor().id() { if CACHE.get(&uid).is_none() && !gonna_fetch.contains(&uid) { gonna_fetch.insert(uid.clone()); - sub_tasks.push(Box::pin(fetch_and_update(U::User, uid, auth))); + sub_tasks.push(Box::pin(fetch_and_update(U::Actor, uid, auth))); } } } for user in actors_seen { - sub_tasks.push(Box::pin(fetch_and_update(U::User, user, auth))); + sub_tasks.push(Box::pin(fetch_and_update(U::Actor, user, auth))); } futures::future::join_all(sub_tasks).await; @@ -269,9 +269,9 @@ async fn fetch_and_update_with_user(kind: U, id: String, auth: Auth) { if let Some(actor_id) = match kind { U::Object => obj.attributed_to().id(), U::Activity => obj.actor().id(), - U::User | U::Context => None, + U::Actor | U::Context => None, } { - fetch_and_update(U::User, actor_id, auth).await; + fetch_and_update(U::Actor, actor_id, auth).await; } } } diff --git a/web/src/components/user.rs b/web/src/components/user.rs index c99d1fb..82c69d7 100644 --- a/web/src/components/user.rs +++ b/web/src/components/user.rs @@ -10,7 +10,7 @@ pub fn ActorStrip(object: crate::Object) -> impl IntoView { let domain = object.id().unwrap_or_default().replace("https://", "").split('/').next().unwrap_or_default().to_string(); let avatar = object.icon().get().map(|x| x.url().id().unwrap_or(DEFAULT_AVATAR_URL.into())).unwrap_or(DEFAULT_AVATAR_URL.into()); view! { - + {username}@{domain} } @@ -20,11 +20,11 @@ pub fn ActorStrip(object: crate::Object) -> impl IntoView { pub fn ActorBanner(object: crate::Object) -> impl IntoView { match object.as_ref() { serde_json::Value::String(id) => view! { - + }, serde_json::Value::Object(_) => { let uid = object.id().unwrap_or_default().to_string(); - let uri = Uri::web(U::User, &uid); + let uri = Uri::web(U::Actor, &uid); let avatar_url = object.icon().get().map(|x| x.url().id().unwrap_or(DEFAULT_AVATAR_URL.into())).unwrap_or(DEFAULT_AVATAR_URL.into()); let display_name = object.name().unwrap_or_default().to_string(); let username = object.preferred_username().unwrap_or_default().to_string(); diff --git a/web/src/page/debug.rs b/web/src/page/debug.rs index 7a28467..08fa9d2 100644 --- a/web/src/page/debug.rs +++ b/web/src/page/debug.rs @@ -84,7 +84,7 @@ pub fn DebugPage() -> impl IntoView { " raw :: " obj " :: " - usr + usr " :: " ext " :: " diff --git a/web/src/page/object.rs b/web/src/page/object.rs index 53e9377..01e7247 100644 --- a/web/src/page/object.rs +++ b/web/src/page/object.rs @@ -21,9 +21,9 @@ pub fn ObjectPage(tl: Timeline) -> impl IntoView { let obj = Arc::new(obj); if let Some(author) = obj.attributed_to().id() { if let Ok(user) = Http::fetch::( - &Uri::api(U::User, &author, true), auth + &Uri::api(U::Actor, &author, true), auth ).await { - CACHE.put(Uri::full(U::User, &author), Arc::new(user)); + CACHE.put(Uri::full(U::Actor, &author), Arc::new(user)); } } CACHE.put(Uri::full(U::Object, &oid), obj.clone()); diff --git a/web/src/page/search.rs b/web/src/page/search.rs index cf86996..8596b79 100644 --- a/web/src/page/search.rs +++ b/web/src/page/search.rs @@ -11,7 +11,7 @@ pub fn SearchPage() -> impl IntoView { let user = create_local_resource( move || use_query_map().get().get("q").cloned().unwrap_or_default(), move |q| { - let user_fetch = Uri::api(U::User, &q, true); + let user_fetch = Uri::api(U::Actor, &q, true); async move { Some(Arc::new(Http::fetch::(&user_fetch, auth).await.ok()?)) } } ); diff --git a/web/src/page/user.rs b/web/src/page/user.rs index 2f68b6e..3d83df9 100644 --- a/web/src/page/user.rs +++ b/web/src/page/user.rs @@ -27,16 +27,16 @@ pub fn UserPage(tl: Timeline) -> impl IntoView { .get("id") .cloned() .unwrap_or_default(); - let uid = uriproxy::uri(URL_BASE, uriproxy::UriClass::User, &id); + let uid = uriproxy::uri(URL_BASE, uriproxy::UriClass::Actor, &id); let _uid = uid.clone(); let actor = create_local_resource(move || _uid.clone(), move |id| { async move { - match CACHE.get(&Uri::full(U::User, &id)) { + match CACHE.get(&Uri::full(U::Actor, &id)) { Some(x) => Some(x.clone()), None => { - let user : serde_json::Value = Http::fetch(&Uri::api(U::User, &id, true), auth).await.ok()?; + let user : serde_json::Value = Http::fetch(&Uri::api(U::Actor, &id, true), auth).await.ok()?; let user = Arc::new(user); - CACHE.put(Uri::full(U::User, &id), user.clone()); + CACHE.put(Uri::full(U::Actor, &id), user.clone()); Some(user) }, } @@ -80,7 +80,7 @@ pub fn UserPage(tl: Timeline) -> impl IntoView { let following = object.following_count().unwrap_or(0); let followers = object.followers_count().unwrap_or(0); let statuses = object.statuses_count().unwrap_or(0); - let tl_url = format!("{}/outbox/page", Uri::api(U::User, &id.clone(), false)); + let tl_url = format!("{}/outbox/page", Uri::api(U::Actor, &id.clone(), false)); if !tl.next.get().starts_with(&tl_url) { tl.reset(tl_url); }