mirror of
https://github.com/20kaushik02/spotify-manager.git
synced 2025-12-06 09:54:07 +00:00
forgot to check editable status on the chain opn
This commit is contained in:
parent
852c907d35
commit
ef3a055c06
@ -168,7 +168,9 @@ const getCurrentUsersPlaylistsNextPage: (
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
interface GetPlaylistDetailsFirstPageArgs extends EndpointHandlerWithResArgs {
|
interface GetPlaylistDetailsFirstPageArgs
|
||||||
|
extends Omit<EndpointHandlerWithResArgs, "res"> {
|
||||||
|
res?: Res;
|
||||||
initialFields: string;
|
initialFields: string;
|
||||||
playlistID: string;
|
playlistID: string;
|
||||||
}
|
}
|
||||||
@ -181,16 +183,17 @@ const getPlaylistDetailsFirstPage: (
|
|||||||
initialFields,
|
initialFields,
|
||||||
playlistID,
|
playlistID,
|
||||||
}) => {
|
}) => {
|
||||||
return await singleRequest<GetPlaylistData>({
|
let args: SingleRequestArgs = {
|
||||||
authHeaders,
|
authHeaders,
|
||||||
res,
|
|
||||||
path: `/playlists/${playlistID}/`,
|
path: `/playlists/${playlistID}/`,
|
||||||
config: {
|
config: {
|
||||||
params: {
|
params: {
|
||||||
fields: initialFields,
|
fields: initialFields,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
|
if (res) args.res = res;
|
||||||
|
return await singleRequest<GetPlaylistData>(args);
|
||||||
};
|
};
|
||||||
|
|
||||||
interface GetPlaylistDetailsNextPageArgs extends EndpointHandlerWithResArgs {
|
interface GetPlaylistDetailsNextPageArgs extends EndpointHandlerWithResArgs {
|
||||||
@ -254,7 +257,9 @@ const removePlaylistItems: (
|
|||||||
// non-endpoints, i.e. convenience wrappers
|
// non-endpoints, i.e. convenience wrappers
|
||||||
// ---------
|
// ---------
|
||||||
|
|
||||||
interface CheckPlaylistEditableArgs extends EndpointHandlerWithResArgs {
|
interface CheckPlaylistEditableArgs
|
||||||
|
extends Omit<EndpointHandlerWithResArgs, "res"> {
|
||||||
|
res?: Res;
|
||||||
playlistID: string;
|
playlistID: string;
|
||||||
userID: string;
|
userID: string;
|
||||||
}
|
}
|
||||||
@ -272,12 +277,13 @@ const checkPlaylistEditable: (
|
|||||||
userID,
|
userID,
|
||||||
}) => {
|
}) => {
|
||||||
let checkFields = ["collaborative", "owner(id)"];
|
let checkFields = ["collaborative", "owner(id)"];
|
||||||
const { resp, error, message } = await getPlaylistDetailsFirstPage({
|
let args: GetPlaylistDetailsFirstPageArgs = {
|
||||||
res,
|
|
||||||
authHeaders,
|
authHeaders,
|
||||||
initialFields: checkFields.join(),
|
initialFields: checkFields.join(),
|
||||||
playlistID,
|
playlistID,
|
||||||
});
|
};
|
||||||
|
if (res) args.res = res;
|
||||||
|
const { resp, error, message } = await getPlaylistDetailsFirstPage(args);
|
||||||
if (!resp) return { status: false, error, message };
|
if (!resp) return { status: false, error, message };
|
||||||
|
|
||||||
// https://web.archive.org/web/20241226081630/https://developer.spotify.com/documentation/web-api/concepts/playlists#:~:text=A%20playlist%20can%20also%20be%20made%20collaborative
|
// https://web.archive.org/web/20241226081630/https://developer.spotify.com/documentation/web-api/concepts/playlists#:~:text=A%20playlist%20can%20also%20be%20made%20collaborative
|
||||||
|
|||||||
@ -687,6 +687,19 @@ const populateChain: RequestHandler = async (req, res) => {
|
|||||||
// (although that's a challenge of its own)
|
// (although that's a challenge of its own)
|
||||||
const newGraph = new myGraph(playlistIDs, allLinks);
|
const newGraph = new myGraph(playlistIDs, allLinks);
|
||||||
const affectedPlaylists = newGraph.getAllHeads(rootPl.id);
|
const affectedPlaylists = newGraph.getAllHeads(rootPl.id);
|
||||||
|
|
||||||
|
const editableStatuses = await Promise.all(
|
||||||
|
affectedPlaylists.map((pl) => {
|
||||||
|
return checkPlaylistEditable({
|
||||||
|
authHeaders,
|
||||||
|
playlistID: pl,
|
||||||
|
userID: uID,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
|
if (editableStatuses.some((statusObj) => statusObj.status === false))
|
||||||
|
return null;
|
||||||
|
|
||||||
const affectedPlaylistsTracks = await Promise.all(
|
const affectedPlaylistsTracks = await Promise.all(
|
||||||
affectedPlaylists.map((pl) => {
|
affectedPlaylists.map((pl) => {
|
||||||
return _getPlaylistTracks({ res, authHeaders, playlistID: pl });
|
return _getPlaylistTracks({ res, authHeaders, playlistID: pl });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user