feat(add watchlist): adding midding functionality from overserr

feat(add watchlist): adding missing functionality from overserr
This commit is contained in:
Yalagin
2023-04-27 21:19:36 +07:00
parent 53f6a890b9
commit 5f1c10d50a
30 changed files with 534 additions and 20 deletions

View File

@@ -8,6 +8,7 @@ import Media from '@server/entity/Media';
import { MediaRequest } from '@server/entity/MediaRequest';
import { User } from '@server/entity/User';
import { UserPushSubscription } from '@server/entity/UserPushSubscription';
import { Watchlist } from '@server/entity/Watchlist';
import type { WatchlistResponse } from '@server/interfaces/api/discoverInterfaces';
import type {
QuotaResponse,
@@ -699,8 +700,7 @@ router.get<{ id: string }, WatchlistResponse>(
) {
return next({
status: 403,
message:
"You do not have permission to view this user's Plex Watchlist.",
message: "You do not have permission to view this user's Watchlist.",
});
}
@@ -714,6 +714,24 @@ router.get<{ id: string }, WatchlistResponse>(
});
if (!user?.plexToken) {
if (user) {
const [result, total] = await getRepository(Watchlist).findAndCount({
where: { requestedBy: { id: user?.id } },
relations: { requestedBy: true },
// loadRelationIds: true,
take: itemsPerPage,
skip: offset,
});
if (total) {
return res.json({
page: page,
totalPages: total / itemsPerPage,
totalResults: total,
results: result,
});
}
}
// We will just return an empty array if the user has no Plex token
return res.json({
page: 1,