de-global server_is_ours / user_is_local
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
010e4ee35a
commit
59efabbbc2
34 changed files with 179 additions and 169 deletions
|
@ -4,7 +4,15 @@ use std::{io::Cursor, time::Duration};
|
|||
|
||||
use axum::extract::State;
|
||||
use axum_client_ip::InsecureClientIp;
|
||||
use conduit::{debug, error, utils::math::ruma_from_usize, warn};
|
||||
use conduit::{
|
||||
debug, debug_warn, error,
|
||||
utils::{
|
||||
self,
|
||||
content_disposition::{content_disposition_type, make_content_disposition, sanitise_filename},
|
||||
math::ruma_from_usize,
|
||||
},
|
||||
warn, Error, Result,
|
||||
};
|
||||
use image::io::Reader as ImgReader;
|
||||
use ipaddress::IPAddress;
|
||||
use reqwest::Url;
|
||||
|
@ -15,20 +23,13 @@ use ruma::api::client::{
|
|||
get_media_preview,
|
||||
},
|
||||
};
|
||||
use service::{
|
||||
media::{FileMeta, UrlPreviewData},
|
||||
Services,
|
||||
};
|
||||
use webpage::HTML;
|
||||
|
||||
use crate::{
|
||||
debug_warn,
|
||||
service::{
|
||||
media::{FileMeta, UrlPreviewData},
|
||||
server_is_ours, Services,
|
||||
},
|
||||
utils::{
|
||||
self,
|
||||
content_disposition::{content_disposition_type, make_content_disposition, sanitise_filename},
|
||||
},
|
||||
Error, Result, Ruma, RumaResponse,
|
||||
};
|
||||
use crate::{Ruma, RumaResponse};
|
||||
|
||||
/// generated MXC ID (`media-id`) length
|
||||
const MXC_LENGTH: usize = 32;
|
||||
|
@ -218,7 +219,7 @@ pub(crate) async fn get_content_route(
|
|||
cross_origin_resource_policy: Some(CORP_CROSS_ORIGIN.to_owned()),
|
||||
cache_control: Some(CACHE_CONTROL_IMMUTABLE.into()),
|
||||
})
|
||||
} else if !server_is_ours(&body.server_name) && body.allow_remote {
|
||||
} else if !services.globals.server_is_ours(&body.server_name) && body.allow_remote {
|
||||
let response = get_remote_content(
|
||||
services,
|
||||
&mxc,
|
||||
|
@ -308,7 +309,7 @@ pub(crate) async fn get_content_as_filename_route(
|
|||
cross_origin_resource_policy: Some(CORP_CROSS_ORIGIN.to_owned()),
|
||||
cache_control: Some(CACHE_CONTROL_IMMUTABLE.into()),
|
||||
})
|
||||
} else if !server_is_ours(&body.server_name) && body.allow_remote {
|
||||
} else if !services.globals.server_is_ours(&body.server_name) && body.allow_remote {
|
||||
match get_remote_content(
|
||||
services,
|
||||
&mxc,
|
||||
|
@ -408,7 +409,7 @@ pub(crate) async fn get_content_thumbnail_route(
|
|||
cache_control: Some(CACHE_CONTROL_IMMUTABLE.into()),
|
||||
content_disposition,
|
||||
})
|
||||
} else if !server_is_ours(&body.server_name) && body.allow_remote {
|
||||
} else if !services.globals.server_is_ours(&body.server_name) && body.allow_remote {
|
||||
if services
|
||||
.globals
|
||||
.prevent_media_downloads_from()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue