freeze remote media via legacy endpoints

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-08-28 09:16:41 +00:00
parent 1638be0339
commit a934a7f687
2 changed files with 15 additions and 0 deletions

View file

@ -310,6 +310,7 @@ pub async fn fetch_remote_thumbnail_legacy(
media_id: &body.media_id,
};
self.check_legacy_freeze()?;
self.check_fetch_authorized(&mxc)?;
let reponse = self
.services
@ -342,6 +343,7 @@ pub async fn fetch_remote_thumbnail_legacy(
pub async fn fetch_remote_content_legacy(
&self, mxc: &Mxc<'_>, allow_redirect: bool, timeout_ms: Duration,
) -> Result<media::get_content::v3::Response, Error> {
self.check_legacy_freeze()?;
self.check_fetch_authorized(mxc)?;
let response = self
.services
@ -391,3 +393,13 @@ fn check_fetch_authorized(&self, mxc: &Mxc<'_>) -> Result<()> {
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."))))
}