From 14578345e7366a699372ed67a8955f58152f5160 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 7 Aug 2024 14:58:34 -0600 Subject: [PATCH] Return a 404 instead of 500 when clients access media which is frozen (#604) --- CHANGELOG.md | 4 +++- api/r0/download.go | 2 +- api/r0/thumbnail.go | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 121b4e21..bdb54c00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] -*Nothing yet* +### Fixed + +* Return a 404 instead of 500 when clients access media which is frozen. ## [1.3.7] - July 30, 2024 diff --git a/api/r0/download.go b/api/r0/download.go index 5360dcc1..dc48a410 100644 --- a/api/r0/download.go +++ b/api/r0/download.go @@ -96,7 +96,7 @@ func DownloadMedia(r *http.Request, rctx rcontext.RequestContext, auth _apimeta. return _responses.ErrorResponse{ Code: common.ErrCodeNotFound, Message: "authentication is required to download this media", - InternalCode: common.ErrCodeUnauthorized, + InternalCode: common.ErrCodeNotFound, // used to determine http status code } } else if errors.Is(err, common.ErrMediaTooLarge) { return _responses.RequestTooLarge() diff --git a/api/r0/thumbnail.go b/api/r0/thumbnail.go index 48ec314e..4fff646b 100644 --- a/api/r0/thumbnail.go +++ b/api/r0/thumbnail.go @@ -147,7 +147,7 @@ func ThumbnailMedia(r *http.Request, rctx rcontext.RequestContext, auth _apimeta return _responses.ErrorResponse{ Code: common.ErrCodeNotFound, Message: "authentication is required to download this media", - InternalCode: common.ErrCodeUnauthorized, + InternalCode: common.ErrCodeNotFound, // used to determine http status code } } else if errors.Is(err, common.ErrMediaTooLarge) { return _responses.RequestTooLarge()