Make post and profile page redirections work in Mastodon
This commit is contained in:
parent
672564bdad
commit
e7b318c761
3 changed files with 23 additions and 10 deletions
15
CHANGELOG.md
Normal file
15
CHANGELOG.md
Normal file
|
@ -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.
|
|
@ -32,7 +32,7 @@ use super::identifiers::{
|
||||||
};
|
};
|
||||||
use super::receiver::receive_activity;
|
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] = [
|
const CONTENT_TYPES: [&str; 4] = [
|
||||||
AP_MEDIA_TYPE,
|
AP_MEDIA_TYPE,
|
||||||
AS_MEDIA_TYPE,
|
AS_MEDIA_TYPE,
|
||||||
|
|
|
@ -12,8 +12,8 @@ use actix_web::{
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
constants::{AP_MEDIA_TYPE, AS_MEDIA_TYPE},
|
|
||||||
identifiers::{local_actor_id, local_object_id},
|
identifiers::{local_actor_id, local_object_id},
|
||||||
|
views::is_activitypub_request,
|
||||||
};
|
};
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::{get_database_client, DbPool};
|
use crate::database::{get_database_client, DbPool};
|
||||||
|
@ -59,10 +59,9 @@ async fn profile_page_redirect_view(
|
||||||
|
|
||||||
pub fn profile_page_redirect() -> Resource {
|
pub fn profile_page_redirect() -> Resource {
|
||||||
web::resource("/profile/{profile_id}")
|
web::resource("/profile/{profile_id}")
|
||||||
.guard(
|
.guard(guard::fn_guard(|ctx| {
|
||||||
guard::Any(guard::Header("Accept", AP_MEDIA_TYPE))
|
is_activitypub_request(ctx.head().headers())
|
||||||
.or(guard::Header("Accept", AS_MEDIA_TYPE))
|
}))
|
||||||
)
|
|
||||||
.route(web::get().to(profile_page_redirect_view))
|
.route(web::get().to(profile_page_redirect_view))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,9 +81,8 @@ async fn post_page_redirect_view(
|
||||||
|
|
||||||
pub fn post_page_redirect() -> Resource {
|
pub fn post_page_redirect() -> Resource {
|
||||||
web::resource("/post/{object_id}")
|
web::resource("/post/{object_id}")
|
||||||
.guard(
|
.guard(guard::fn_guard(|ctx| {
|
||||||
guard::Any(guard::Header("Accept", AP_MEDIA_TYPE))
|
is_activitypub_request(ctx.head().headers())
|
||||||
.or(guard::Header("Accept", AS_MEDIA_TYPE))
|
}))
|
||||||
)
|
|
||||||
.route(web::get().to(post_page_redirect_view))
|
.route(web::get().to(post_page_redirect_view))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue