fix: context querying

This commit is contained in:
əlemi 2024-05-20 21:23:30 +02:00
parent 32dd5163bb
commit 49cee6cafa
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 4 additions and 7 deletions

View file

@ -26,13 +26,7 @@ pub async fn page(
Query(page): Query<Pagination>, Query(page): Query<Pagination>,
AuthIdentity(auth): AuthIdentity, AuthIdentity(auth): AuthIdentity,
) -> crate::Result<JsonLD<serde_json::Value>> { ) -> crate::Result<JsonLD<serde_json::Value>> {
let context = if id.starts_with('+') { let context = ctx.context_id(&id);
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
};
crate::server::builders::paginate( crate::server::builders::paginate(
url!(ctx, "/context/{id}/page"), url!(ctx, "/context/{id}/page"),

View file

@ -121,6 +121,9 @@ impl Context {
// TODO remove this!! // TODO remove this!!
pub fn context_id(&self, id: &str) -> String { pub fn context_id(&self, id: &str) -> String {
if id.starts_with("tag:") {
return id.to_string();
}
uriproxy::uri(self.base(), UriClass::Context, id) uriproxy::uri(self.base(), UriClass::Context, id)
} }