freeze remote media via legacy endpoints
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
1638be0339
commit
a934a7f687
2 changed files with 15 additions and 0 deletions
|
@ -292,6 +292,8 @@ pub struct Config {
|
||||||
#[serde(default = "true_fn")]
|
#[serde(default = "true_fn")]
|
||||||
pub allow_legacy_media: bool,
|
pub allow_legacy_media: bool,
|
||||||
#[serde(default = "true_fn")]
|
#[serde(default = "true_fn")]
|
||||||
|
pub freeze_legacy_media: bool,
|
||||||
|
#[serde(default = "true_fn")]
|
||||||
pub media_startup_check: bool,
|
pub media_startup_check: bool,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub media_compat_file_link: bool,
|
pub media_compat_file_link: bool,
|
||||||
|
@ -748,6 +750,7 @@ impl fmt::Display for Config {
|
||||||
line("Media compatibility filesystem links", &self.media_compat_file_link.to_string());
|
line("Media compatibility filesystem links", &self.media_compat_file_link.to_string());
|
||||||
line("Prune missing media from database", &self.prune_missing_media.to_string());
|
line("Prune missing media from database", &self.prune_missing_media.to_string());
|
||||||
line("Allow legacy (unauthenticated) media", &self.allow_legacy_media.to_string());
|
line("Allow legacy (unauthenticated) media", &self.allow_legacy_media.to_string());
|
||||||
|
line("Freeze legacy (unauthenticated) media", &self.freeze_legacy_media.to_string());
|
||||||
line("Prevent Media Downloads From", {
|
line("Prevent Media Downloads From", {
|
||||||
let mut lst = vec![];
|
let mut lst = vec![];
|
||||||
for domain in &self.prevent_media_downloads_from {
|
for domain in &self.prevent_media_downloads_from {
|
||||||
|
|
|
@ -310,6 +310,7 @@ pub async fn fetch_remote_thumbnail_legacy(
|
||||||
media_id: &body.media_id,
|
media_id: &body.media_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.check_legacy_freeze()?;
|
||||||
self.check_fetch_authorized(&mxc)?;
|
self.check_fetch_authorized(&mxc)?;
|
||||||
let reponse = self
|
let reponse = self
|
||||||
.services
|
.services
|
||||||
|
@ -342,6 +343,7 @@ pub async fn fetch_remote_thumbnail_legacy(
|
||||||
pub async fn fetch_remote_content_legacy(
|
pub async fn fetch_remote_content_legacy(
|
||||||
&self, mxc: &Mxc<'_>, allow_redirect: bool, timeout_ms: Duration,
|
&self, mxc: &Mxc<'_>, allow_redirect: bool, timeout_ms: Duration,
|
||||||
) -> Result<media::get_content::v3::Response, Error> {
|
) -> Result<media::get_content::v3::Response, Error> {
|
||||||
|
self.check_legacy_freeze()?;
|
||||||
self.check_fetch_authorized(mxc)?;
|
self.check_fetch_authorized(mxc)?;
|
||||||
let response = self
|
let response = self
|
||||||
.services
|
.services
|
||||||
|
@ -391,3 +393,13 @@ fn check_fetch_authorized(&self, mxc: &Mxc<'_>) -> Result<()> {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[implement(super::Service)]
|
||||||
|
fn check_legacy_freeze(&self) -> Result<()> {
|
||||||
|
self.services
|
||||||
|
.server
|
||||||
|
.config
|
||||||
|
.freeze_legacy_media
|
||||||
|
.then_some(())
|
||||||
|
.ok_or(err!(Request(NotFound("Remote media is frozen."))))
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue