fix: ap proxy is now on /fetch?uri=...
to avoid nginx proxy conflicts
This commit is contained in:
parent
b2745d2695
commit
2cbf7aff9f
5 changed files with 6 additions and 26 deletions
|
@ -19,7 +19,7 @@ pub async fn cloak(ctx: upub::Context, post_contents: bool, objects: bool, actor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if post_contents {
|
if objects {
|
||||||
let mut stream = upub::model::object::Entity::find()
|
let mut stream = upub::model::object::Entity::find()
|
||||||
.filter(upub::model::object::Column::Image.is_not_null())
|
.filter(upub::model::object::Column::Image.is_not_null())
|
||||||
.filter(upub::model::object::Column::Image.not_like(&local_base))
|
.filter(upub::model::object::Column::Image.not_like(&local_base))
|
||||||
|
|
|
@ -66,7 +66,7 @@ pub async fn view(
|
||||||
.set_endpoints(Node::object(
|
.set_endpoints(Node::object(
|
||||||
apb::new()
|
apb::new()
|
||||||
.set_shared_inbox(Some(&upub::url!(ctx, "/inbox")))
|
.set_shared_inbox(Some(&upub::url!(ctx, "/inbox")))
|
||||||
.set_proxy_url(Some(&upub::url!(ctx, "/proxy")))
|
.set_proxy_url(Some(&upub::url!(ctx, "/fetch")))
|
||||||
));
|
));
|
||||||
|
|
||||||
if auth.is(&uid) {
|
if auth.is(&uid) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use apb::{LD, ActorMut, BaseMut, ObjectMut, PublicKeyMut};
|
use apb::{LD, ActorMut, BaseMut, ObjectMut, PublicKeyMut};
|
||||||
use axum::{extract::{Path, Query, State}, http::HeaderMap, response::{IntoResponse, Redirect, Response}, Form};
|
use axum::{extract::{Path, Query, State}, http::HeaderMap, response::{IntoResponse, Redirect, Response}};
|
||||||
use reqwest::Method;
|
use reqwest::Method;
|
||||||
use upub::{traits::{Cloaker, Fetcher}, Context};
|
use upub::{traits::{Cloaker, Fetcher}, Context};
|
||||||
|
|
||||||
|
@ -39,22 +39,12 @@ pub async fn view(
|
||||||
).into_response())
|
).into_response())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn proxy_path(
|
|
||||||
State(ctx): State<Context>,
|
|
||||||
AuthIdentity(auth): AuthIdentity,
|
|
||||||
Path(uri): Path<String>,
|
|
||||||
) -> crate::ApiResult<impl IntoResponse> {
|
|
||||||
let query = uriproxy::expand(&uri)
|
|
||||||
.ok_or_else(crate::ApiError::bad_request)?;
|
|
||||||
proxy(ctx, query, auth).await
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, serde::Deserialize)]
|
||||||
pub struct ProxyQuery {
|
pub struct ProxyQuery {
|
||||||
uri: String,
|
uri: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn proxy_get(
|
pub async fn ap_fetch(
|
||||||
State(ctx): State<Context>,
|
State(ctx): State<Context>,
|
||||||
AuthIdentity(auth): AuthIdentity,
|
AuthIdentity(auth): AuthIdentity,
|
||||||
Query(query): Query<ProxyQuery>,
|
Query(query): Query<ProxyQuery>,
|
||||||
|
@ -62,14 +52,6 @@ pub async fn proxy_get(
|
||||||
proxy(ctx, query.uri, auth).await
|
proxy(ctx, query.uri, auth).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn proxy_form(
|
|
||||||
State(ctx): State<Context>,
|
|
||||||
AuthIdentity(auth): AuthIdentity,
|
|
||||||
Form(query): Form<String>,
|
|
||||||
) -> crate::ApiResult<impl IntoResponse> {
|
|
||||||
proxy(ctx, query, auth).await
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn proxy_cloak(
|
pub async fn proxy_cloak(
|
||||||
State(ctx): State<Context>,
|
State(ctx): State<Context>,
|
||||||
AuthIdentity(auth): AuthIdentity,
|
AuthIdentity(auth): AuthIdentity,
|
||||||
|
|
|
@ -22,9 +22,7 @@ impl ActivityPubRouter for Router<upub::Context> {
|
||||||
// core server inbox/outbox, maybe for feeds? TODO do we need these?
|
// core server inbox/outbox, maybe for feeds? TODO do we need these?
|
||||||
.route("/", get(ap::application::view))
|
.route("/", get(ap::application::view))
|
||||||
// fetch route, to debug and retreive remote objects
|
// fetch route, to debug and retreive remote objects
|
||||||
.route("/proxy", post(ap::application::proxy_form))
|
.route("/fetch", get(ap::application::ap_fetch))
|
||||||
.route("/proxy", get(ap::application::proxy_get))
|
|
||||||
.route("/proxy/:uri", get(ap::application::proxy_path))
|
|
||||||
.route("/proxy/:hmac/:uri", get(ap::application::proxy_cloak))
|
.route("/proxy/:hmac/:uri", get(ap::application::proxy_cloak))
|
||||||
.route("/inbox", post(ap::inbox::post))
|
.route("/inbox", post(ap::inbox::post))
|
||||||
.route("/inbox", get(ap::inbox::get))
|
.route("/inbox", get(ap::inbox::get))
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub fn DebugPage() -> impl IntoView {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug_fetch(&format!("{URL_BASE}/proxy?uri={query}"), auth, set_error).await
|
debug_fetch(&format!("{URL_BASE}/fetch?uri={query}"), auth, set_error).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue