Try to fix federation with GNU Social
This commit is contained in:
parent
6af5b8c24d
commit
52112996c5
1 changed files with 8 additions and 10 deletions
|
@ -33,6 +33,14 @@ use super::identifiers::{
|
||||||
use super::receiver::receive_activity;
|
use super::receiver::receive_activity;
|
||||||
|
|
||||||
pub fn is_activitypub_request(headers: &HeaderMap) -> bool {
|
pub fn is_activitypub_request(headers: &HeaderMap) -> bool {
|
||||||
|
let maybe_user_agent = headers.get("User-Agent")
|
||||||
|
.and_then(|value| value.to_str().ok());
|
||||||
|
if let Some(user_agent) = maybe_user_agent {
|
||||||
|
if user_agent.contains("THIS. IS. GNU social!!!!") {
|
||||||
|
// GNU Social doesn't send valid Accept headers
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
};
|
||||||
const CONTENT_TYPES: [&str; 4] = [
|
const CONTENT_TYPES: [&str; 4] = [
|
||||||
AP_MEDIA_TYPE,
|
AP_MEDIA_TYPE,
|
||||||
AS_MEDIA_TYPE,
|
AS_MEDIA_TYPE,
|
||||||
|
@ -45,16 +53,6 @@ pub fn is_activitypub_request(headers: &HeaderMap) -> bool {
|
||||||
.and_then(|value| value.split(',').next())
|
.and_then(|value| value.split(',').next())
|
||||||
.unwrap_or("");
|
.unwrap_or("");
|
||||||
return CONTENT_TYPES.contains(&content_type_str);
|
return CONTENT_TYPES.contains(&content_type_str);
|
||||||
} else {
|
|
||||||
// No Accept header
|
|
||||||
let maybe_user_agent = headers.get("User-Agent")
|
|
||||||
.and_then(|value| value.to_str().ok());
|
|
||||||
if let Some(user_agent) = maybe_user_agent {
|
|
||||||
if user_agent.contains("THIS. IS. GNU social!!!!") {
|
|
||||||
// GNU Social doesn't add Accept header
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue