mirror of
https://github.com/sct/overseerr.git
synced 2025-09-28 13:04:23 +02:00
fix: availability sync requests (#3460)
* fix: modified media status handling when media has been deleted fix: requests will now be updated to completed on scan fix: modified components to display deleted as a status fix: corrected media status switching away from deleted fix: modified components to display deleted as a status fix: corrected media status switching away from deleted fix: base scanner will set requests to completed correctly fix: mark available button correctly sets requests as completed fix: status will now stay deleted after declined request refactor: request completion handling moved to entity fix: prevented notifications from sending to old deleted requests refactor: cleaned up code and added more detail to logs refactor: updated to reflect latest availability sync changes * fix: fetch requests only if necessary in db and remove unneeded code * fix: update request button logic to accomodate specials fix: remove completed filtering in tv details * fix: correctly set seasons status when using the manual button * refactor: improve reliability of season request completion refactor: remove seasonrequest code * fix: send notification for 4k movies fix: same for shows * feat: add completed filter to requests list refactor: correct label
This commit is contained in:
@@ -2,6 +2,7 @@ import TautulliAPI from '@server/api/tautulli';
|
||||
import { MediaStatus, MediaType } from '@server/constants/media';
|
||||
import { getRepository } from '@server/datasource';
|
||||
import Media from '@server/entity/Media';
|
||||
import Season from '@server/entity/Season';
|
||||
import { User } from '@server/entity/User';
|
||||
import type {
|
||||
MediaResultsResponse,
|
||||
@@ -98,6 +99,7 @@ mediaRoutes.post<
|
||||
isAuthenticated(Permission.MANAGE_REQUESTS),
|
||||
async (req, res, next) => {
|
||||
const mediaRepository = getRepository(Media);
|
||||
const seasonRepository = getRepository(Season);
|
||||
|
||||
const media = await mediaRepository.findOne({
|
||||
where: { id: Number(req.params.id) },
|
||||
@@ -112,11 +114,25 @@ mediaRoutes.post<
|
||||
switch (req.params.status) {
|
||||
case 'available':
|
||||
media[is4k ? 'status4k' : 'status'] = MediaStatus.AVAILABLE;
|
||||
|
||||
if (media.mediaType === MediaType.TV) {
|
||||
// Mark all seasons available
|
||||
media.seasons.forEach((season) => {
|
||||
const expectedSeasons = req.body.seasons ?? [];
|
||||
|
||||
for (const expectedSeason of expectedSeasons) {
|
||||
let season = media.seasons.find(
|
||||
(s) => s.seasonNumber === expectedSeason?.seasonNumber
|
||||
);
|
||||
|
||||
if (!season) {
|
||||
// Create the season if it doesn't exist
|
||||
season = seasonRepository.create({
|
||||
seasonNumber: expectedSeason?.seasonNumber,
|
||||
});
|
||||
media.seasons.push(season);
|
||||
}
|
||||
|
||||
season[is4k ? 'status4k' : 'status'] = MediaStatus.AVAILABLE;
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'partial':
|
||||
|
Reference in New Issue
Block a user