diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1b15fa9 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,15 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). + +## [Unreleased] + +### Changed + +- Changed text on Ethereum page. + +### Fixed + +- Fixed post and profile page redirections. diff --git a/src/activitypub/views.rs b/src/activitypub/views.rs index b193719..88ea1e3 100644 --- a/src/activitypub/views.rs +++ b/src/activitypub/views.rs @@ -32,7 +32,7 @@ use super::identifiers::{ }; use super::receiver::receive_activity; -fn is_activitypub_request(headers: &HeaderMap) -> bool { +pub fn is_activitypub_request(headers: &HeaderMap) -> bool { const CONTENT_TYPES: [&str; 4] = [ AP_MEDIA_TYPE, AS_MEDIA_TYPE, diff --git a/src/web_client/views.rs b/src/web_client/views.rs index 3c22b48..b61bd18 100644 --- a/src/web_client/views.rs +++ b/src/web_client/views.rs @@ -12,8 +12,8 @@ use actix_web::{ use uuid::Uuid; use crate::activitypub::{ - constants::{AP_MEDIA_TYPE, AS_MEDIA_TYPE}, identifiers::{local_actor_id, local_object_id}, + views::is_activitypub_request, }; use crate::config::Config; use crate::database::{get_database_client, DbPool}; @@ -59,10 +59,9 @@ async fn profile_page_redirect_view( pub fn profile_page_redirect() -> Resource { web::resource("/profile/{profile_id}") - .guard( - guard::Any(guard::Header("Accept", AP_MEDIA_TYPE)) - .or(guard::Header("Accept", AS_MEDIA_TYPE)) - ) + .guard(guard::fn_guard(|ctx| { + is_activitypub_request(ctx.head().headers()) + })) .route(web::get().to(profile_page_redirect_view)) } @@ -82,9 +81,8 @@ async fn post_page_redirect_view( pub fn post_page_redirect() -> Resource { web::resource("/post/{object_id}") - .guard( - guard::Any(guard::Header("Accept", AP_MEDIA_TYPE)) - .or(guard::Header("Accept", AS_MEDIA_TYPE)) - ) + .guard(guard::fn_guard(|ctx| { + is_activitypub_request(ctx.head().headers()) + })) .route(web::get().to(post_page_redirect_view)) }