X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Froutes%2Fsrc%2Ffeeds.rs;h=96e718631b392b80f6abeb2ae9bde9f1dcb7c0e4;hb=c8063f3267cf2b3622f1fdc69128c6b55feefbbc;hp=a71871abcd0a75e1570cae65d5679bfb0d210292;hpb=88215bfbc98b70595035426c06cfe67f4a9ab0ab;p=lemmy.git diff --git a/crates/routes/src/feeds.rs b/crates/routes/src/feeds.rs index a71871ab..96e71863 100644 --- a/crates/routes/src/feeds.rs +++ b/crates/routes/src/feeds.rs @@ -13,14 +13,19 @@ use lemmy_db_schema::{ }; use lemmy_db_views::{ post_view::PostQuery, - structs::{PostView, SiteView}, + structs::{LocalUserView, PostView, SiteView}, }; use lemmy_db_views_actor::{ comment_reply_view::CommentReplyQuery, person_mention_view::PersonMentionQuery, structs::{CommentReplyView, PersonMentionView}, }; -use lemmy_utils::{claims::Claims, error::LemmyError, utils::markdown::markdown_to_html}; +use lemmy_utils::{ + cache_header::cache_1hour, + claims::Claims, + error::LemmyError, + utils::markdown::markdown_to_html, +}; use once_cell::sync::Lazy; use rss::{ extension::dublincore::DublinCoreExtensionBuilder, @@ -65,10 +70,15 @@ enum RequestType { } pub fn config(cfg: &mut web::ServiceConfig) { - cfg - .route("/feeds/{type}/{name}.xml", web::get().to(get_feed)) - .route("/feeds/all.xml", web::get().to(get_all_feed)) - .route("/feeds/local.xml", web::get().to(get_local_feed)); + cfg.service( + web::scope("/feeds") + .route("/{type}/{name}.xml", web::get().to(get_feed)) + .route("/all.xml", web::get().to(get_all_feed).wrap(cache_1hour())) + .route( + "/local.xml", + web::get().to(get_local_feed).wrap(cache_1hour()), + ), + ); } static RSS_NAMESPACE: Lazy> = Lazy::new(|| { @@ -316,7 +326,7 @@ async fn get_feed_front( ) -> Result { let site_view = SiteView::read_local(pool).await?; let local_user_id = LocalUserId(Claims::decode(jwt, jwt_secret)?.claims.sub); - let local_user = LocalUser::read(pool, local_user_id).await?; + let local_user = LocalUserView::read(pool, local_user_id).await?; let posts = PostQuery { listing_type: (Some(ListingType::Subscribed)), @@ -363,7 +373,7 @@ async fn get_feed_inbox( let replies = CommentReplyQuery { recipient_id: (Some(person_id)), my_person_id: (Some(person_id)), - show_bot_accounts: (Some(show_bot_accounts)), + show_bot_accounts: (show_bot_accounts), sort: (Some(sort)), limit: (Some(RSS_FETCH_LIMIT)), ..Default::default() @@ -374,7 +384,7 @@ async fn get_feed_inbox( let mentions = PersonMentionQuery { recipient_id: (Some(person_id)), my_person_id: (Some(person_id)), - show_bot_accounts: (Some(show_bot_accounts)), + show_bot_accounts: (show_bot_accounts), sort: (Some(sort)), limit: (Some(RSS_FETCH_LIMIT)), ..Default::default()