From 904d7bec2fe10c37530c694161d19b42c47897ea Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sat, 26 Nov 2022 21:34:38 +0100 Subject: [PATCH] Builds lemmy_routes in parallel with lemmy_apub --- Cargo.lock | 1 - crates/apub/src/fetcher/webfinger.rs | 17 +---------------- crates/routes/Cargo.toml | 1 - crates/routes/src/webfinger.rs | 3 +-- crates/utils/src/lib.rs | 16 ++++++++++++++++ 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 95475492..2d1f70bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2231,7 +2231,6 @@ dependencies = [ "diesel", "futures", "lemmy_api_common", - "lemmy_apub", "lemmy_db_schema", "lemmy_db_views", "lemmy_db_views_actor", diff --git a/crates/apub/src/fetcher/webfinger.rs b/crates/apub/src/fetcher/webfinger.rs index 4a0ff4fd..3ec6fcf8 100644 --- a/crates/apub/src/fetcher/webfinger.rs +++ b/crates/apub/src/fetcher/webfinger.rs @@ -4,25 +4,10 @@ use anyhow::anyhow; use itertools::Itertools; use lemmy_api_common::LemmyContext; use lemmy_db_schema::newtypes::DbUrl; -use lemmy_utils::error::LemmyError; -use serde::{Deserialize, Serialize}; +use lemmy_utils::{error::LemmyError, WebfingerResponse}; use tracing::debug; use url::Url; -#[derive(Serialize, Deserialize, Debug)] -pub struct WebfingerLink { - pub rel: Option, - #[serde(rename = "type")] - pub kind: Option, - pub href: Option, -} - -#[derive(Serialize, Deserialize, Debug)] -pub struct WebfingerResponse { - pub subject: String, - pub links: Vec, -} - /// Turns a person id like `@name@example.com` into an apub ID, like `https://example.com/user/name`, /// using webfinger. #[tracing::instrument(skip_all)] diff --git a/crates/routes/Cargo.toml b/crates/routes/Cargo.toml index a2778349..c5349a20 100644 --- a/crates/routes/Cargo.toml +++ b/crates/routes/Cargo.toml @@ -17,7 +17,6 @@ lemmy_db_views = { workspace = true } lemmy_db_views_actor = { workspace = true } lemmy_db_schema = { workspace = true } lemmy_api_common = { workspace = true } -lemmy_apub = { workspace = true } diesel = { workspace = true } actix-web = { workspace = true } anyhow = { workspace = true } diff --git a/crates/routes/src/webfinger.rs b/crates/routes/src/webfinger.rs index 7d9ff2bf..68482a8d 100644 --- a/crates/routes/src/webfinger.rs +++ b/crates/routes/src/webfinger.rs @@ -1,12 +1,11 @@ use actix_web::{web, web::Query, HttpResponse}; use anyhow::Context; use lemmy_api_common::LemmyContext; -use lemmy_apub::fetcher::webfinger::{WebfingerLink, WebfingerResponse}; use lemmy_db_schema::{ source::{community::Community, person::Person}, traits::ApubActor, }; -use lemmy_utils::{error::LemmyError, location_info}; +use lemmy_utils::{error::LemmyError, location_info, WebfingerLink, WebfingerResponse}; use serde::Deserialize; use url::Url; diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index beaf173b..eeb58843 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -16,7 +16,9 @@ mod test; pub mod utils; pub mod version; +use serde::{Deserialize, Serialize}; use std::{fmt, time::Duration}; +use url::Url; pub type ConnectionId = usize; @@ -31,6 +33,20 @@ impl fmt::Display for IpAddr { } } +#[derive(Serialize, Deserialize, Debug)] +pub struct WebfingerLink { + pub rel: Option, + #[serde(rename = "type")] + pub kind: Option, + pub href: Option, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct WebfingerResponse { + pub subject: String, + pub links: Vec, +} + #[macro_export] macro_rules! location_info { () => { -- 2.44.1