diff options
Diffstat (limited to 'server/src/routes')
-rw-r--r-- | server/src/routes/federation.rs | 22 | ||||
-rw-r--r-- | server/src/routes/feeds.rs | 31 | ||||
-rw-r--r-- | server/src/routes/index.rs | 2 | ||||
-rw-r--r-- | server/src/routes/nodeinfo.rs | 12 | ||||
-rw-r--r-- | server/src/routes/webfinger.rs | 24 |
5 files changed, 30 insertions, 61 deletions
diff --git a/server/src/routes/federation.rs b/server/src/routes/federation.rs index fe6e3365..ebab139a 100644 --- a/server/src/routes/federation.rs +++ b/server/src/routes/federation.rs @@ -1,17 +1,15 @@ -use crate::{ - apub::{ - comment::get_apub_comment, - community::*, - community_inbox::community_inbox, - post::get_apub_post, - shared_inbox::shared_inbox, - user::*, - user_inbox::user_inbox, - APUB_JSON_CONTENT_TYPE, - }, - settings::Settings, +use crate::apub::{ + comment::get_apub_comment, + community::*, + community_inbox::community_inbox, + post::get_apub_post, + shared_inbox::shared_inbox, + user::*, + user_inbox::user_inbox, + APUB_JSON_CONTENT_TYPE, }; use actix_web::*; +use lemmy_utils::settings::Settings; pub fn config(cfg: &mut web::ServiceConfig) { if Settings::get().federation.enabled { diff --git a/server/src/routes/feeds.rs b/server/src/routes/feeds.rs index a1c2ba58..1322feb4 100644 --- a/server/src/routes/feeds.rs +++ b/server/src/routes/feeds.rs @@ -1,26 +1,21 @@ -use crate::{ - blocking, - db::{ - comment_view::{ReplyQueryBuilder, ReplyView}, - community::Community, - post_view::{PostQueryBuilder, PostView}, - site_view::SiteView, - user::{Claims, User_}, - user_mention_view::{UserMentionQueryBuilder, UserMentionView}, - ListingType, - SortType, - }, - markdown_to_html, - routes::DbPoolParam, - settings::Settings, - LemmyError, -}; +use crate::{api::claims::Claims, blocking, routes::DbPoolParam, LemmyError}; use actix_web::{error::ErrorBadRequest, *}; use chrono::{DateTime, NaiveDateTime, Utc}; use diesel::{ r2d2::{ConnectionManager, Pool}, PgConnection, }; +use lemmy_db::{ + comment_view::{ReplyQueryBuilder, ReplyView}, + community::Community, + post_view::{PostQueryBuilder, PostView}, + site_view::SiteView, + user::User_, + user_mention_view::{UserMentionQueryBuilder, UserMentionView}, + ListingType, + SortType, +}; +use lemmy_utils::{markdown_to_html, settings::Settings}; use rss::{CategoryBuilder, ChannelBuilder, GuidBuilder, Item, ItemBuilder}; use serde::Deserialize; use std::str::FromStr; @@ -131,7 +126,7 @@ fn get_feed_user( ) -> Result<ChannelBuilder, LemmyError> { let site_view = SiteView::read(&conn)?; let user = User_::find_by_username(&conn, &user_name)?; - let user_url = user.get_profile_url(); + let user_url = user.get_profile_url(&Settings::get().hostname); let posts = PostQueryBuilder::create(&conn) .listing_type(ListingType::All) diff --git a/server/src/routes/index.rs b/server/src/routes/index.rs index 2f462aa5..b579a195 100644 --- a/server/src/routes/index.rs +++ b/server/src/routes/index.rs @@ -1,6 +1,6 @@ -use crate::settings::Settings; use actix_files::NamedFile; use actix_web::*; +use lemmy_utils::settings::Settings; pub fn config(cfg: &mut web::ServiceConfig) { cfg diff --git a/server/src/routes/nodeinfo.rs b/server/src/routes/nodeinfo.rs index ff728fe3..5094c2f1 100644 --- a/server/src/routes/nodeinfo.rs +++ b/server/src/routes/nodeinfo.rs @@ -1,13 +1,7 @@ -use crate::{ - apub::get_apub_protocol_string, - blocking, - db::site_view::SiteView, - routes::DbPoolParam, - version, - LemmyError, - Settings, -}; +use crate::{blocking, routes::DbPoolParam, version, LemmyError}; use actix_web::{body::Body, error::ErrorBadRequest, *}; +use lemmy_db::site_view::SiteView; +use lemmy_utils::{get_apub_protocol_string, settings::Settings}; use serde::{Deserialize, Serialize}; use url::Url; diff --git a/server/src/routes/webfinger.rs b/server/src/routes/webfinger.rs index af021dd5..e616de0e 100644 --- a/server/src/routes/webfinger.rs +++ b/server/src/routes/webfinger.rs @@ -1,12 +1,7 @@ -use crate::{ - blocking, - db::{community::Community, user::User_}, - routes::DbPoolParam, - LemmyError, - Settings, -}; +use crate::{blocking, routes::DbPoolParam, LemmyError}; use actix_web::{error::ErrorBadRequest, web::Query, *}; -use regex::Regex; +use lemmy_db::{community::Community, user::User_}; +use lemmy_utils::{settings::Settings, WEBFINGER_COMMUNITY_REGEX, WEBFINGER_USER_REGEX}; use serde::{Deserialize, Serialize}; #[derive(Deserialize)] @@ -40,19 +35,6 @@ pub fn config(cfg: &mut web::ServiceConfig) { } } -lazy_static! { - static ref WEBFINGER_COMMUNITY_REGEX: Regex = Regex::new(&format!( - "^group:([a-z0-9_]{{3, 20}})@{}$", - Settings::get().hostname - )) - .unwrap(); - static ref WEBFINGER_USER_REGEX: Regex = Regex::new(&format!( - "^acct:([a-z0-9_]{{3, 20}})@{}$", - Settings::get().hostname - )) - .unwrap(); -} - /// Responds to webfinger requests of the following format. There isn't any real documentation for /// this, but it described in this blog post: /// https://mastodon.social/.well-known/webfinger?resource=acct:gargron@mastodon.social |