mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-13 07:42:31 +02:00
Update serverfolder enable/disable
This commit is contained in:
@@ -9,7 +9,7 @@ const findById = async (user: AuthUser, options: { id: string }) => {
|
||||
const { id } = options;
|
||||
|
||||
const album = await prisma.album.findUnique({
|
||||
include: helpers.albums.include({ songs: true }),
|
||||
include: helpers.albums.include(user, { songs: true }),
|
||||
where: { id },
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ const findMany = async (options: AlbumFindManyOptions) => {
|
||||
prisma.albumRating.findMany({
|
||||
include: {
|
||||
album: {
|
||||
include: helpers.albums.include({ songs: false, user }),
|
||||
include: helpers.albums.include(user, { songs: false }),
|
||||
},
|
||||
},
|
||||
orderBy: { value: orderBy },
|
||||
@@ -78,7 +78,7 @@ const findMany = async (options: AlbumFindManyOptions) => {
|
||||
},
|
||||
}),
|
||||
prisma.album.findMany({
|
||||
include: helpers.albums.include({ songs: false, user }),
|
||||
include: helpers.albums.include(user, { songs: false }),
|
||||
skip,
|
||||
take,
|
||||
where: {
|
||||
@@ -95,7 +95,7 @@ const findMany = async (options: AlbumFindManyOptions) => {
|
||||
where: { OR: helpers.shared.serverFolderFilter(serverFolderIds) },
|
||||
}),
|
||||
prisma.album.findMany({
|
||||
include: helpers.albums.include({ songs: false, user }),
|
||||
include: helpers.albums.include(user, { songs: false }),
|
||||
orderBy: [helpers.albums.sort(sortBy, orderBy)],
|
||||
skip,
|
||||
take,
|
||||
|
||||
@@ -370,8 +370,10 @@ const refresh = async (options: { id: string }) => {
|
||||
|
||||
const fullScan = async (options: { id: string; serverFolderId?: string[] }) => {
|
||||
const { id, serverFolderId } = options;
|
||||
|
||||
// Only allow scan of enabled folders
|
||||
const server = await prisma.server.findUnique({
|
||||
include: { serverFolders: true },
|
||||
include: { serverFolders: { where: { enabled: true } } },
|
||||
where: { id },
|
||||
});
|
||||
|
||||
@@ -544,14 +546,52 @@ const disableUrlById = async (user: AuthUser) => {
|
||||
return null;
|
||||
};
|
||||
|
||||
const findFolderById = async (options: { id: string }) => {
|
||||
const url = await prisma.serverFolder.findUnique({
|
||||
where: { id: options.id },
|
||||
});
|
||||
|
||||
if (!url) {
|
||||
throw ApiError.notFound('Folder not found.');
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
const deleteFolderById = async (options: { id: string }) => {
|
||||
return null;
|
||||
};
|
||||
|
||||
const enableFolderById = async (options: { id: string }) => {
|
||||
await prisma.serverFolder.update({
|
||||
data: { enabled: true },
|
||||
where: { id: options.id },
|
||||
});
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
const disableFolderById = async (options: { id: string }) => {
|
||||
await prisma.serverFolder.update({
|
||||
data: { enabled: false },
|
||||
where: { id: options.id },
|
||||
});
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export const serversService = {
|
||||
create,
|
||||
createUrl,
|
||||
deleteById,
|
||||
deleteFolderById,
|
||||
deleteUrlById,
|
||||
disableFolderById,
|
||||
disableUrlById,
|
||||
enableFolderById,
|
||||
enableUrlById,
|
||||
findById,
|
||||
findFolderById,
|
||||
findMany,
|
||||
findServerUrlById,
|
||||
findUrlById,
|
||||
|
||||
Reference in New Issue
Block a user