Fixed error with incorrectly encoded osu user names
This commit is contained in:
parent
09060344f4
commit
d3da468a93
@ -50,9 +50,13 @@ class UserDetailsController(
|
|||||||
ResponseEntity.badRequest().build()
|
ResponseEntity.badRequest().build()
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("user-details/{userId}")
|
data class UserDetailsRequest(
|
||||||
fun getUserDetails(@PathVariable userId: String): ResponseEntity<UserDetailsResponse> {
|
val userId: String
|
||||||
val userDetails = this.userService.getUserDetails(username = userId)
|
)
|
||||||
|
|
||||||
|
@PostMapping("user-details")
|
||||||
|
fun getUserDetails(@RequestBody request: UserDetailsRequest): ResponseEntity<UserDetailsResponse> {
|
||||||
|
val userDetails = this.userService.getUserDetails(username = request.userId)
|
||||||
?: return ResponseEntity.notFound().build()
|
?: return ResponseEntity.notFound().build()
|
||||||
|
|
||||||
var suspiciousScoresCondition = this.scoreService.getDefaultCondition()
|
var suspiciousScoresCondition = this.scoreService.getDefaultCondition()
|
||||||
|
|||||||
@ -10,9 +10,11 @@ import org.springframework.beans.factory.InitializingBean
|
|||||||
import org.springframework.beans.factory.annotation.Value
|
import org.springframework.beans.factory.annotation.Value
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
import java.net.URLEncoder
|
||||||
import java.net.http.HttpClient
|
import java.net.http.HttpClient
|
||||||
import java.net.http.HttpRequest
|
import java.net.http.HttpRequest
|
||||||
import java.net.http.HttpResponse
|
import java.net.http.HttpResponse
|
||||||
|
import java.nio.charset.StandardCharsets
|
||||||
import java.util.concurrent.atomic.AtomicInteger
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
|
|
||||||
class InvalidOsuApiKeyException() : Exception()
|
class InvalidOsuApiKeyException() : Exception()
|
||||||
@ -228,7 +230,7 @@ class OsuApi(
|
|||||||
val accessToken = this.tokenService.getAccessToken()
|
val accessToken = this.tokenService.getAccessToken()
|
||||||
|
|
||||||
val encodedUserId = userId.replace(' ', '_')
|
val encodedUserId = userId.replace(' ', '_')
|
||||||
val uriBuilder = StringBuilder("https://osu.ppy.sh/api/v2/users/$encodedUserId")
|
val uriBuilder = StringBuilder("https://osu.ppy.sh/api/v2/users/${URLEncoder.encode(encodedUserId, StandardCharsets.UTF_8.toString())}")
|
||||||
|
|
||||||
if (mode != null) uriBuilder.append("/$mode")
|
if (mode != null) uriBuilder.append("/$mode")
|
||||||
if (key != null) uriBuilder.append("?key=$key")
|
if (key != null) uriBuilder.append("?key=$key")
|
||||||
|
|||||||
@ -68,7 +68,10 @@ export class ViewUserComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
) { }
|
) { }
|
||||||
|
|
||||||
getUserInfo(): Observable<UserInfo> {
|
getUserInfo(): Observable<UserInfo> {
|
||||||
return this.httpClient.get<UserInfo>(`${environment.apiUrl}/user-details/${this.userId}`);
|
const body = {
|
||||||
|
userId: this.userId
|
||||||
|
}
|
||||||
|
return this.httpClient.post<UserInfo>(`${environment.apiUrl}/user-details`, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(): void {
|
ngOnChanges(): void {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user