|
- {object.in_reply_to().id().map(|reply| view! {
+ {object.in_reply_to().id().str().map(|reply| view! {
reply
})}
diff --git a/web/src/components/post.rs b/web/src/components/post.rs
index 9470d3c1..6008632a 100644
--- a/web/src/components/post.rs
+++ b/web/src/components/post.rs
@@ -1,4 +1,4 @@
-use apb::{ActivityMut, Base, BaseMut, Object, ObjectMut};
+use apb::{field::OptionalString, ActivityMut, Base, BaseMut, Object, ObjectMut};
use leptos::*;
use crate::{prelude::*, WEBFINGER};
@@ -12,7 +12,7 @@ pub struct ReplyControls {
impl ReplyControls {
pub fn reply(&self, oid: &str) {
if let Some(obj) = CACHE.get(oid) {
- self.context.set(obj.context().id());
+ self.context.set(obj.context().id().str());
self.reply_to.set(obj.id().ok().map(|x| x.to_string()));
}
}
@@ -24,7 +24,7 @@ impl ReplyControls {
}
fn post_author(post_id: &str) -> Option {
- let usr = CACHE.get(post_id)?.attributed_to().id()?;
+ let usr = CACHE.get(post_id)?.attributed_to().id().str()?;
CACHE.get(&usr)
}
diff --git a/web/src/components/timeline.rs b/web/src/components/timeline.rs
index c7604129..5864008c 100644
--- a/web/src/components/timeline.rs
+++ b/web/src/components/timeline.rs
@@ -1,6 +1,6 @@
use std::{collections::BTreeSet, pin::Pin, sync::Arc};
-use apb::{Activity, ActivityMut, Base, Object};
+use apb::{field::OptionalString, Activity, ActivityMut, Base, Object};
use leptos::*;
use leptos_use::{signal_throttled, use_element_size, use_window_scroll, UseElementSizeReturn};
use crate::prelude::*;
@@ -68,8 +68,8 @@ impl Timeline {
feed.append(&mut older);
self.feed.set(feed);
- if let Some(next) = collection.next().id() {
- self.next.set(next);
+ if let Ok(next) = collection.next().id() {
+ self.next.set(next.to_string());
} else {
self.over.set(true);
}
@@ -86,9 +86,9 @@ pub fn TimelineRepliesRecursive(tl: Timeline, root: String) -> impl IntoView {
.filter_map(|x| CACHE.get(&x))
.filter(|x| match x.object_type() {
Ok(apb::ObjectType::Activity(apb::ActivityType::Create)) => {
- let Some(oid) = x.object().id() else { return false; };
+ let Some(oid) = x.object().id().str() else { return false; };
let Some(object) = CACHE.get(&oid) else { return false; };
- let Some(reply) = object.in_reply_to().id() else { return false; };
+ let Some(reply) = object.in_reply_to().id().str() else { return false; };
reply == root
},
Ok(apb::ObjectType::Activity(_)) => x.object().id().map(|o| o == root).unwrap_or(false),
@@ -199,7 +199,7 @@ async fn process_activities(activities: Vec, auth: Auth) -> V
// save embedded object if present
if let Some(object) = activity.object().get() {
// also fetch actor attributed to
- if let Some(attributed_to) = object.attributed_to().id() {
+ if let Some(attributed_to) = object.attributed_to().id().str() {
actors_seen.insert(attributed_to);
}
if let Ok(object_uri) = object.id() {
@@ -208,7 +208,7 @@ async fn process_activities(activities: Vec, auth: Auth) -> V
tracing::warn!("embedded object without id: {object:?}");
}
} else { // try fetching it
- if let Some(object_id) = activity.object().id() {
+ if let Some(object_id) = activity.object().id().str() {
if !gonna_fetch.contains(&object_id) {
let fetch_kind = match activity_type {
apb::ActivityType::Follow => U::Actor,
@@ -221,25 +221,25 @@ async fn process_activities(activities: Vec, auth: Auth) -> V
}
// save activity, removing embedded object
- let object_id = activity.object().id();
- if let Ok(activity_id) = activity.id() {
+ let object_id = activity.object().id().str();
+ if let Some(activity_id) = activity.id().str() {
out.push(activity_id.to_string());
CACHE.put(
activity_id.to_string(),
Arc::new(activity.clone().set_object(apb::Node::maybe_link(object_id)))
);
- } else if let Some(object_id) = activity.object().id() {
+ } else if let Some(object_id) = activity.object().id().str() {
out.push(object_id);
}
- if let Some(uid) = activity.attributed_to().id() {
+ if let Some(uid) = activity.attributed_to().id().str() {
if CACHE.get(&uid).is_none() && !gonna_fetch.contains(&uid) {
gonna_fetch.insert(uid.clone());
sub_tasks.push(Box::pin(fetch_and_update(U::Actor, uid, auth)));
}
}
- if let Some(uid) = activity.actor().id() {
+ if let Some(uid) = activity.actor().id().str() {
if CACHE.get(&uid).is_none() && !gonna_fetch.contains(&uid) {
gonna_fetch.insert(uid.clone());
sub_tasks.push(Box::pin(fetch_and_update(U::Actor, uid, auth)));
@@ -267,8 +267,8 @@ async fn fetch_and_update_with_user(kind: U, id: String, auth: Auth) {
fetch_and_update(kind, id.clone(), auth).await;
if let Some(obj) = CACHE.get(&id) {
if let Some(actor_id) = match kind {
- U::Object => obj.attributed_to().id(),
- U::Activity => obj.actor().id(),
+ U::Object => obj.attributed_to().id().str(),
+ U::Activity => obj.actor().id().str(),
U::Actor | U::Context => None,
} {
fetch_and_update(U::Actor, actor_id, auth).await;
diff --git a/web/src/components/user.rs b/web/src/components/user.rs
index 82c69d74..fd731f4e 100644
--- a/web/src/components/user.rs
+++ b/web/src/components/user.rs
@@ -1,14 +1,14 @@
use leptos::*;
use crate::{prelude::*, DEFAULT_AVATAR_URL};
-use apb::{Activity, ActivityMut, Actor, Base, Object, ObjectMut};
+use apb::{field::OptionalString, Activity, ActivityMut, Actor, Base, Object, ObjectMut};
#[component]
pub fn ActorStrip(object: crate::Object) -> impl IntoView {
let actor_id = object.id().unwrap_or_default().to_string();
let username = object.preferred_username().unwrap_or_default().to_string();
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());
+ let avatar = object.icon().get().map(|x| x.url().id().str().unwrap_or(DEFAULT_AVATAR_URL.into())).unwrap_or(DEFAULT_AVATAR_URL.into());
view! {
{username}@{domain}
@@ -25,7 +25,7 @@ pub fn ActorBanner(object: crate::Object) -> impl IntoView {
serde_json::Value::Object(_) => {
let uid = object.id().unwrap_or_default().to_string();
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 avatar_url = object.icon().get().map(|x| x.url().id().str().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();
let domain = object.id().unwrap_or_default().replace("https://", "").split('/').next().unwrap_or_default().to_string();
@@ -55,7 +55,7 @@ pub fn FollowRequestButtons(activity_id: String, actor_id: String) -> impl IntoV
// TODO lmao what is going on with this double move / triple clone ???????????
let _activity_id = activity_id.clone();
let _actor_id = actor_id.clone();
- let from_actor = CACHE.get(&activity_id).map(|x| x.actor().id().unwrap_or_default()).unwrap_or_default();
+ let from_actor = CACHE.get(&activity_id).map(|x| x.actor().id().str().unwrap_or_default()).unwrap_or_default();
let _from_actor = from_actor.clone();
if actor_id == auth.user_id() {
Some(view! {
diff --git a/web/src/config.rs b/web/src/config.rs
index d5d44c27..41d96e9e 100644
--- a/web/src/config.rs
+++ b/web/src/config.rs
@@ -61,9 +61,9 @@ impl FiltersConfig {
let mut reply_filter = true;
if
- item.in_reply_to().id().is_some() ||
+ item.in_reply_to().id().is_ok() ||
item.object().get().map(|x|
- x.in_reply_to().id().is_some()
+ x.in_reply_to().id().is_ok()
).unwrap_or(false)
{
reply_filter = self.replies;
diff --git a/web/src/page/object.rs b/web/src/page/object.rs
index ca4d7cd7..13fcb079 100644
--- a/web/src/page/object.rs
+++ b/web/src/page/object.rs
@@ -24,11 +24,11 @@ pub fn ObjectPage(tl: Timeline) -> impl IntoView {
None => {
let obj = Http::fetch::(&Uri::api(U::Object, &oid, true), auth).await.ok()?;
let obj = Arc::new(obj);
- if let Some(author) = obj.attributed_to().id() {
+ if let Ok(author) = obj.attributed_to().id() {
if let Ok(user) = Http::fetch::(
- &Uri::api(U::Actor, &author, true), auth
+ &Uri::api(U::Actor, author, true), auth
).await {
- CACHE.put(Uri::full(U::Actor, &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/user.rs b/web/src/page/user.rs
index ffdce3f5..68bcb9a4 100644
--- a/web/src/page/user.rs
+++ b/web/src/page/user.rs
@@ -4,7 +4,7 @@ use leptos::*;
use leptos_router::*;
use crate::{prelude::*, DEFAULT_AVATAR_URL};
-use apb::{Base, Actor, ActivityMut, Object, ObjectMut};
+use apb::{field::OptionalString, ActivityMut, Actor, Base, Object, ObjectMut};
fn send_follow_request(target: String) {
let auth = use_context::().expect("missing auth context");
@@ -72,8 +72,8 @@ pub fn UserPage(tl: Timeline) -> impl IntoView {
},
Some(Some(object)) => {
let uid = object.id().unwrap_or_default().to_string();
- let avatar_url = object.icon().get().map(|x| x.url().id().unwrap_or(DEFAULT_AVATAR_URL.into())).unwrap_or(DEFAULT_AVATAR_URL.into());
- let background_url = object.image().get().map(|x| x.url().id().unwrap_or(DEFAULT_AVATAR_URL.into())).unwrap_or(DEFAULT_AVATAR_URL.into());
+ let avatar_url = object.icon().get().map(|x| x.url().id().str().unwrap_or(DEFAULT_AVATAR_URL.into())).unwrap_or(DEFAULT_AVATAR_URL.into());
+ let background_url = object.image().get().map(|x| x.url().id().str().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();
let summary = object.summary().unwrap_or_default().to_string();
|