|
|
|
@ -147,19 +147,25 @@ mediaRoutes.post<
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (req.params.status === 'available') {
|
|
|
|
|
const request = await requestRepository.findOne({
|
|
|
|
|
const requests = await requestRepository.find({
|
|
|
|
|
relations: {
|
|
|
|
|
media: true,
|
|
|
|
|
},
|
|
|
|
|
where: { media: { id: media.id }, is4k: is4k },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const requestIds = requests.map((request) => request.id);
|
|
|
|
|
|
|
|
|
|
if (requestIds.length > 0) {
|
|
|
|
|
await requestRepository.update(
|
|
|
|
|
{ media: { id: request?.id } },
|
|
|
|
|
{ id: In(requestIds) },
|
|
|
|
|
{ status: MediaRequestStatus.COMPLETED }
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
request?.seasons.forEach(async (season) => {
|
|
|
|
|
requests
|
|
|
|
|
.flatMap((request) => request.seasons)
|
|
|
|
|
.forEach(async (season) => {
|
|
|
|
|
await seasonRequestRepository.update(season.id, {
|
|
|
|
|
status: MediaRequestStatus.COMPLETED,
|
|
|
|
|
});
|
|
|
|
|