From 49cee6cafa0048531a4858fc7796ea6ca0761d26 Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 20 May 2024 21:23:30 +0200 Subject: [PATCH] fix: context querying --- src/routes/activitypub/context.rs | 8 +------- src/server/context.rs | 3 +++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/routes/activitypub/context.rs b/src/routes/activitypub/context.rs index 7278018a..42422ea8 100644 --- a/src/routes/activitypub/context.rs +++ b/src/routes/activitypub/context.rs @@ -26,13 +26,7 @@ pub async fn page( Query(page): Query, AuthIdentity(auth): AuthIdentity, ) -> crate::Result> { - let context = if id.starts_with('+') { - id.replacen('+', "https://", 1).replace('@', "/") - } else if id.starts_with("tag:") { - id.clone() - } else { - url!(ctx, "/context/{id}") // TODO need a better way to figure out which ones are our contexts - }; + let context = ctx.context_id(&id); crate::server::builders::paginate( url!(ctx, "/context/{id}/page"), diff --git a/src/server/context.rs b/src/server/context.rs index 765d9371..20216227 100644 --- a/src/server/context.rs +++ b/src/server/context.rs @@ -121,6 +121,9 @@ impl Context { // TODO remove this!! pub fn context_id(&self, id: &str) -> String { + if id.starts_with("tag:") { + return id.to_string(); + } uriproxy::uri(self.base(), UriClass::Context, id) }