fix(web): prefetch users when as object, fix links
This commit is contained in:
parent
4f477fd072
commit
b6cac77bf2
2 changed files with 12 additions and 2 deletions
|
@ -10,6 +10,11 @@ pub fn ActivityLine(activity: crate::Object) -> impl IntoView {
|
|||
let actor_id = activity.actor().id().unwrap_or_default();
|
||||
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(FetchKind::User, &object_id),
|
||||
// TODO for update check what's being updated
|
||||
_ => Uri::web(FetchKind::Object, &object_id),
|
||||
};
|
||||
view! {
|
||||
<div>
|
||||
<span class="ml-1-r">
|
||||
|
@ -17,7 +22,7 @@ pub fn ActivityLine(activity: crate::Object) -> impl IntoView {
|
|||
</span>
|
||||
<span style="float:right">
|
||||
<code class="color moreinfo" title={activity.published().map(|x| x.to_rfc2822())} >
|
||||
<a class="upub-title clean" title={object_id.clone()} href={Uri::web(FetchKind::Object, &object_id)} >
|
||||
<a class="upub-title clean" title={object_id} href={href} >
|
||||
{kind.as_ref().to_string()}
|
||||
</a>
|
||||
<PrivacyMarker addressed=activity.addressed() />
|
||||
|
|
|
@ -210,6 +210,7 @@ async fn process_activities(activities: Vec<serde_json::Value>, auth: Auth) -> V
|
|||
let mut out = Vec::new();
|
||||
|
||||
for activity in activities {
|
||||
let activity_type = activity.activity_type().unwrap_or(apb::ActivityType::Activity);
|
||||
// save embedded object if present
|
||||
if let Some(object) = activity.object().get() {
|
||||
// also fetch actor attributed to
|
||||
|
@ -224,8 +225,12 @@ async fn process_activities(activities: Vec<serde_json::Value>, auth: Auth) -> V
|
|||
} else { // try fetching it
|
||||
if let Some(object_id) = activity.object().id() {
|
||||
if !gonna_fetch.contains(&object_id) {
|
||||
let fetch_kind = match activity_type {
|
||||
apb::ActivityType::Follow => FetchKind::User,
|
||||
_ => FetchKind::Object,
|
||||
};
|
||||
gonna_fetch.insert(object_id.clone());
|
||||
sub_tasks.push(Box::pin(fetch_and_update_with_user(FetchKind::Object, object_id, auth)));
|
||||
sub_tasks.push(Box::pin(fetch_and_update_with_user(fetch_kind, object_id, auth)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue