mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Add endpoint and delete user test
This commit is contained in:
parent
640f59d0c9
commit
369a8907af
3 changed files with 22 additions and 0 deletions
|
@ -14,6 +14,7 @@ import io.activej.inject.module.Module;
|
||||||
import io.activej.launchers.http.MultithreadedHttpServerLauncher;
|
import io.activej.launchers.http.MultithreadedHttpServerLauncher;
|
||||||
import me.kavin.piped.consts.Constants;
|
import me.kavin.piped.consts.Constants;
|
||||||
import me.kavin.piped.utils.*;
|
import me.kavin.piped.utils.*;
|
||||||
|
import me.kavin.piped.utils.resp.DeleteUserRequest;
|
||||||
import me.kavin.piped.utils.resp.ErrorResponse;
|
import me.kavin.piped.utils.resp.ErrorResponse;
|
||||||
import me.kavin.piped.utils.resp.LoginRequest;
|
import me.kavin.piped.utils.resp.LoginRequest;
|
||||||
import me.kavin.piped.utils.resp.SubscriptionUpdateRequest;
|
import me.kavin.piped.utils.resp.SubscriptionUpdateRequest;
|
||||||
|
@ -327,6 +328,15 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return getErrorResponse(e, request.getPath());
|
return getErrorResponse(e, request.getPath());
|
||||||
}
|
}
|
||||||
|
})).map(POST, "/user/delete", AsyncServlet.ofBlocking(executor, request -> {
|
||||||
|
try {
|
||||||
|
DeleteUserRequest body = Constants.mapper.readValue(request.loadBody().getResult().asArray(),
|
||||||
|
DeleteUserRequest.class);
|
||||||
|
return getJsonResponse(ResponseHelper.deleteUserResponse(request.getHeader(AUTHORIZATION), body.password),
|
||||||
|
"private");
|
||||||
|
} catch (Exception e) {
|
||||||
|
return getErrorResponse(e, request.getPath());
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return new CustomServletDecorator(router);
|
return new CustomServletDecorator(router);
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package me.kavin.piped.utils.resp;
|
||||||
|
|
||||||
|
public class DeleteUserRequest {
|
||||||
|
|
||||||
|
public String password;
|
||||||
|
|
||||||
|
}
|
|
@ -107,3 +107,8 @@ curl ${CURLOPTS[@]} $HOST/user/playlists/remove -X POST -H "Content-Type: applic
|
||||||
|
|
||||||
# Delete Playlist Test
|
# Delete Playlist Test
|
||||||
curl ${CURLOPTS[@]} $HOST/user/playlists/delete -X POST -H "Content-Type: application/json" -H "Authorization: $AUTH_TOKEN" -d $(jq -n --compact-output --arg playlistId $PLAYLIST_ID '{"playlistId": $playlistId}') || exit 1
|
curl ${CURLOPTS[@]} $HOST/user/playlists/delete -X POST -H "Content-Type: application/json" -H "Authorization: $AUTH_TOKEN" -d $(jq -n --compact-output --arg playlistId $PLAYLIST_ID '{"playlistId": $playlistId}') || exit 1
|
||||||
|
|
||||||
|
DELETE_REQ=$(jq -n --compact-output --arg password "$PASS" '{"password": $password}')
|
||||||
|
|
||||||
|
# Delete User Test
|
||||||
|
curl ${CURLOPTS[@]} $HOST/user/delete -X POST -H "Content-Type: application/json" -H "Authorization: $AUTH_TOKEN" -d $DELETE_REQ || exit 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue