From 8a1afadea046f9dc7b2eb56456777fbfc64ef857 Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 13 May 2024 01:48:51 +0200 Subject: [PATCH] feat: logged in user can search by webfinger more expensive than "localized" +..@..@ urls because must always make one extra request but allows easier searching --- src/routes/activitypub/user/mod.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/routes/activitypub/user/mod.rs b/src/routes/activitypub/user/mod.rs index 84256ac..d474c24 100644 --- a/src/routes/activitypub/user/mod.rs +++ b/src/routes/activitypub/user/mod.rs @@ -7,7 +7,7 @@ pub mod following; use axum::extract::{Path, Query, State}; use sea_orm::{ColumnTrait, EntityTrait, QueryFilter, QuerySelect, SelectColumns}; -use apb::{ActorMut, Node, ObjectMut}; +use apb::{ActorMut, Node}; use crate::{errors::UpubError, model::{self, user}, server::{auth::AuthIdentity, fetcher::Fetcher, Context}, url}; use super::{jsonld::LD, JsonLD, TryFetch}; @@ -19,8 +19,13 @@ pub async fn view( Path(id): Path, Query(query): Query, ) -> crate::Result> { - let uid = ctx.uri("users", id.clone()); + let mut uid = ctx.uri("users", id.clone()); if auth.is_local() && query.fetch && !ctx.is_local(&uid) { + if id.starts_with('@') { + if let Some((user, host)) = id.replacen('@', "", 1).split_once('@') { + uid = ctx.webfinger(user, host).await?; + } + } ctx.fetch_user(&uid).await?; }