Handle 410 HTTP response code for AP objects

This commit is contained in:
Chocobozzz 2024-05-30 10:28:20 +02:00
parent 8d4902b3ba
commit 6a4db88e5c
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 12 additions and 6 deletions

View File

@ -57,8 +57,10 @@ async function doRefresh <T extends MActorFull | MActorAccountChannelId> (option
return { refreshed: true, actor }
} catch (err) {
if ((err as PeerTubeRequestError).statusCode === HttpStatusCode.NOT_FOUND_404) {
logger.info('Deleting actor %s because there is a 404 in refresh actor.', actor.url, lTags())
const statusCode = (err as PeerTubeRequestError).statusCode
if (statusCode === HttpStatusCode.NOT_FOUND_404 || statusCode === HttpStatusCode.GONE_410) {
logger.info('Deleting actor %s because there is a 404/410 in refresh actor.', actor.url, lTags())
actor.Account
? await actor.Account.destroy()

View File

@ -33,8 +33,10 @@ async function refreshVideoPlaylistIfNeeded (videoPlaylist: MVideoPlaylistOwner)
return videoPlaylist
} catch (err) {
if ((err as PeerTubeRequestError).statusCode === HttpStatusCode.NOT_FOUND_404) {
logger.info('Cannot refresh not existing playlist %s. Deleting it.', videoPlaylist.url, lTags())
const statusCode = (err as PeerTubeRequestError).statusCode
if (statusCode === HttpStatusCode.NOT_FOUND_404 || statusCode === HttpStatusCode.GONE_410) {
logger.info('Cannot refresh not existing playlist (404/410 error code) %s. Deleting it.', videoPlaylist.url, lTags())
await videoPlaylist.destroy()
return undefined

View File

@ -43,8 +43,10 @@ async function refreshVideoIfNeeded (options: {
return video
} catch (err) {
if ((err as PeerTubeRequestError).statusCode === HttpStatusCode.NOT_FOUND_404) {
logger.info('Cannot refresh remote video %s: video does not exist anymore. Deleting it.', video.url, lTags())
const statusCode = (err as PeerTubeRequestError).statusCode
if (statusCode === HttpStatusCode.NOT_FOUND_404 || statusCode === HttpStatusCode.GONE_410) {
logger.info('Cannot refresh remote video %s: video does not exist anymore (404/410 error code). Deleting it.', video.url, lTags())
// Video does not exist anymore
await video.destroy()