Compare commits
No commits in common. "2d3421e2c37e4639f9cab3bf6f379d683df7c844" and "646696a49ed8c07ffd2b10e489ad1e1f47196ae9" have entirely different histories.
2d3421e2c3
...
646696a49e
10 changed files with 11 additions and 147 deletions
|
@ -9,7 +9,6 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/acrate-inbox/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/acrate-nodeinfo/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/acrate-nodeinfo/tests" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/acrate-webfinger/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="acrate" uuid="8258414e-095d-430b-a0a5-b48e72af23a9">
|
||||
<driver-ref>postgresql</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:postgresql:///acrate</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$/acrate-core/migrations/2024-11-14-031744_Add webfinger table/up.sql" dialect="GenericSQL" />
|
||||
</component>
|
||||
</project>
|
|
@ -1,8 +0,0 @@
|
|||
DROP FUNCTION get_meta_property;
|
||||
DROP FUNCTION get_meta_link;
|
||||
DROP FUNCTION get_meta_aliases;
|
||||
|
||||
DROP TABLE meta_property;
|
||||
DROP TABLE meta_link_property;
|
||||
DROP TABLE meta_link;
|
||||
DROP TABLE meta_alias;
|
|
@ -1,47 +0,0 @@
|
|||
CREATE TABLE meta_alias (
|
||||
id UUID DEFAULT gen_random_uuid(),
|
||||
pattern BPCHAR NOT NULL,
|
||||
alias BPCHAR NOT NULL,
|
||||
|
||||
CONSTRAINT unique_aliases UNIQUE (alias),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE meta_link (
|
||||
id UUID DEFAULT gen_random_uuid(),
|
||||
pattern BPCHAR NOT NULL,
|
||||
rel BPCHAR NOT NULL,
|
||||
type BPCHAR,
|
||||
href BPCHAR,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE meta_link_property (
|
||||
id UUID DEFAULT gen_random_uuid(),
|
||||
link UUID REFERENCES meta_link (id),
|
||||
rel BPCHAR NOT NULL,
|
||||
value BPCHAR,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE meta_property (
|
||||
id UUID DEFAULT gen_random_uuid(),
|
||||
pattern BPCHAR NOT NULL,
|
||||
value BPCHAR,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE FUNCTION get_meta_aliases(BPCHAR) RETURNS SETOF meta_alias AS $$
|
||||
SELECT * FROM meta_alias WHERE meta_alias.pattern ILIKE $1;
|
||||
$$ LANGUAGE SQL;
|
||||
|
||||
CREATE FUNCTION get_meta_link(BPCHAR) RETURNS SETOF meta_link AS $$
|
||||
SELECT * FROM meta_link WHERE meta_link.pattern ILIKE $1;
|
||||
$$ LANGUAGE SQL;
|
||||
|
||||
CREATE FUNCTION get_meta_property(BPCHAR) RETURNS SETOF meta_property AS $$
|
||||
SELECT * FROM meta_property WHERE meta_property.pattern ILIKE $1;
|
||||
$$ LANGUAGE SQL;
|
|
@ -1,46 +0,0 @@
|
|||
// @generated automatically by Diesel CLI.
|
||||
|
||||
diesel::table! {
|
||||
meta_alias (id) {
|
||||
id -> Uuid,
|
||||
pattern -> Bpchar,
|
||||
alias -> Bpchar,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
meta_link (id) {
|
||||
id -> Uuid,
|
||||
pattern -> Bpchar,
|
||||
rel -> Bpchar,
|
||||
#[sql_name = "type"]
|
||||
type_ -> Nullable<Bpchar>,
|
||||
href -> Nullable<Bpchar>,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
meta_link_property (id) {
|
||||
id -> Uuid,
|
||||
link -> Nullable<Uuid>,
|
||||
rel -> Bpchar,
|
||||
value -> Nullable<Bpchar>,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
meta_property (id) {
|
||||
id -> Uuid,
|
||||
pattern -> Bpchar,
|
||||
value -> Nullable<Bpchar>,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::joinable!(meta_link_property -> meta_link (link));
|
||||
|
||||
diesel::allow_tables_to_appear_in_same_query!(
|
||||
meta_alias,
|
||||
meta_link,
|
||||
meta_link_property,
|
||||
meta_property,
|
||||
);
|
|
@ -5,10 +5,8 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1.0.93"
|
||||
axum = { version = "0.7.7", features = ["macros"] }
|
||||
axum-extra = { version = "0.9.4", features = ["query"] }
|
||||
axum = "0.7.7"
|
||||
log = "0.4.22"
|
||||
micronfig = "0.3.0"
|
||||
pretty_env_logger = "0.5.0"
|
||||
serde = { version = "1.0.215", features = ["derive"] }
|
||||
tokio = { version = "1.41.1", features = ["macros", "net", "rt-multi-thread"] }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
micronfig::config!(
|
||||
ACRATE_WEBFINGER_BIND_ADDRESS: String,
|
||||
ACRATE_INBOX_BIND_ADDRESS: String,
|
||||
);
|
||||
|
|
|
@ -11,11 +11,11 @@ async fn main() -> anyhow::Result<std::convert::Infallible> {
|
|||
|
||||
log::trace!("Creating Axum router...");
|
||||
let app = axum::Router::new()
|
||||
.route("/.well-known/webfinger", axum::routing::get(route::webfinger_handler));
|
||||
.route("/inbox", axum::routing::post(route::inbox_handler));
|
||||
log::trace!("Axum router created successfully!");
|
||||
|
||||
log::trace!("Creating Tokio listener...");
|
||||
let bind_address = config::ACRATE_WEBFINGER_BIND_ADDRESS();
|
||||
let bind_address = config::ACRATE_INBOX_BIND_ADDRESS();
|
||||
let listener = tokio::net::TcpListener::bind(bind_address)
|
||||
.await
|
||||
.context("failed to bind listener to address")?;
|
||||
|
|
|
@ -1,22 +1,8 @@
|
|||
use axum::http::StatusCode;
|
||||
use axum_extra::extract::Query;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct WebfingerQuery {
|
||||
pub resource: String,
|
||||
|
||||
#[serde(default)]
|
||||
pub rel: Vec<String>,
|
||||
}
|
||||
|
||||
#[axum::debug_handler]
|
||||
pub async fn webfinger_handler(
|
||||
Query(WebfingerQuery {resource, rel}): Query<WebfingerQuery>
|
||||
) -> StatusCode {
|
||||
log::info!("Handling a WebFinger request!");
|
||||
log::debug!("Resource is: {resource:#?}");
|
||||
log::debug!("Rel is: {rel:#?}");
|
||||
|
||||
StatusCode::NO_CONTENT
|
||||
#[allow(unreachable_code)]
|
||||
pub async fn inbox_handler() {
|
||||
todo!("pre-validation hook");
|
||||
todo!("validate signature");
|
||||
todo!("post-validation hook");
|
||||
todo!("database storage");
|
||||
todo!("post-storage hook");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue