From b2717223b3815ede5828d5ad49ce765f1f1a7812 Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 2 May 2024 02:08:34 +0200 Subject: [PATCH] feat(web): add accept/reject buttons under folreqs they never disappear so there's quite some potential for spam but ehh better than nothing for now --- web/src/components/timeline.rs | 10 +++++-- web/src/components/user.rs | 55 +++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/web/src/components/timeline.rs b/web/src/components/timeline.rs index f8058624..1f41e830 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, Base, Object}; +use apb::{Activity, ActivityMut, Base, Object, ObjectMut}; use leptos::*; use crate::prelude::*; @@ -168,7 +168,12 @@ pub fn TimelineFeed(tl: Timeline) -> impl IntoView { }.into_view()), apb::ActivityType::Follow => CACHE.get(&object_id).map(|obj| { - view! {
} + view! { +
+ + +
+ } }.into_view()), _ => None, }; @@ -203,7 +208,6 @@ pub fn TimelineFeed(tl: Timeline) -> impl IntoView { } async fn process_activities(activities: Vec, auth: Auth) -> Vec { - use apb::ActivityMut; let mut sub_tasks : Vec>>> = Vec::new(); let mut gonna_fetch = BTreeSet::new(); let mut actors_seen = BTreeSet::new(); diff --git a/web/src/components/user.rs b/web/src/components/user.rs index f4191f09..a6c01545 100644 --- a/web/src/components/user.rs +++ b/web/src/components/user.rs @@ -1,7 +1,7 @@ use leptos::*; use crate::prelude::*; -use apb::{Actor, Base, Object}; +use apb::{ActivityMut, Actor, Base, Object, ObjectMut}; #[component] pub fn ActorStrip(object: crate::Object) -> impl IntoView { @@ -48,3 +48,56 @@ pub fn ActorBanner(object: crate::Object) -> impl IntoView { } } } + +#[component] +pub fn FollowRequestButtons(activity_id: String, actor_id: String) -> impl IntoView { + let auth = use_context::().expect("missing auth context"); + // TODO lmao what is going on with this double move / triple clone ??????????? + let _activity_id = activity_id.clone(); + let _actor_id = actor_id.clone(); + if actor_id == auth.user_id() { + Some(view! { + + + + }) + } else { + None + } +} + +async fn send_follow_response(kind: apb::ActivityType, target: String, to: String, auth: Auth) { + let payload = serde_json::Value::Object(serde_json::Map::default()) + .set_activity_type(Some(kind)) + .set_object(apb::Node::link(target)) + .set_to(apb::Node::links(vec![to])); + if let Err(e) = Http::post(&auth.outbox(), &payload, auth).await { + tracing::error!("failed posting follow response: {e}"); + } +}