Change discordId type from integer to string across frontend, backend, and API schema for consistency and proper validation.
This commit is contained in:
parent
ea4780cc91
commit
2e7c91bb73
|
|
@ -39,8 +39,9 @@ public class AppealController implements AppealsApi {
|
||||||
private final com.alttd.altitudeweb.services.discord.AppealDiscord appealDiscord;
|
private final com.alttd.altitudeweb.services.discord.AppealDiscord appealDiscord;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<BannedUserResponseDto> getBannedUser(Long discordId) throws Exception {
|
public ResponseEntity<BannedUserResponseDto> getBannedUser(String discordId) throws Exception {
|
||||||
return new ResponseEntity<>(discordAppeal.getBannedUser(discordId), HttpStatus.OK);
|
long discordIdAsLong = Long.parseLong(discordId);
|
||||||
|
return new ResponseEntity<>(discordAppeal.getBannedUser(discordIdAsLong), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RateLimit(limit = 3, timeValue = 1, timeUnit = TimeUnit.HOURS, key = "discordAppeal")
|
@RateLimit(limit = 3, timeValue = 1, timeUnit = TimeUnit.HOURS, key = "discordAppeal")
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import org.springframework.stereotype.Service;
|
||||||
public class BannedUserToBannedUserDtoMapper {
|
public class BannedUserToBannedUserDtoMapper {
|
||||||
|
|
||||||
public BannedUserDto map(BannedUser bannedUser) {
|
public BannedUserDto map(BannedUser bannedUser) {
|
||||||
return new BannedUserDto(bannedUser.userId(), bannedUser.reason(), bannedUser.name(), bannedUser.avatarUrl());
|
return new BannedUserDto(String.valueOf(bannedUser.userId()), bannedUser.reason(), bannedUser.name(), bannedUser.avatarUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ public class DiscordAppealDtoToDiscordAppealMapper {
|
||||||
return new DiscordAppeal(
|
return new DiscordAppeal(
|
||||||
UUID.randomUUID(),
|
UUID.randomUUID(),
|
||||||
loggedInUserUuid,
|
loggedInUserUuid,
|
||||||
discordAppealDto.getDiscordId(),
|
Long.parseLong(discordAppealDto.getDiscordId()),
|
||||||
discordUsername,
|
discordUsername,
|
||||||
discordAppealDto.getAppeal(),
|
discordAppealDto.getAppeal(),
|
||||||
Instant.now(),
|
Instant.now(),
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,8 @@ public class DiscordAppeal {
|
||||||
|
|
||||||
public FormResponseDto submitAppeal(DiscordAppealDto discordAppealDto) {
|
public FormResponseDto submitAppeal(DiscordAppealDto discordAppealDto) {
|
||||||
DiscordAppealDiscord discordAppealDiscord = DiscordAppealDiscord.getInstance();
|
DiscordAppealDiscord discordAppealDiscord = DiscordAppealDiscord.getInstance();
|
||||||
Optional<BannedUser> join = discordAppealDiscord.getBannedUser(discordAppealDto.getDiscordId()).join();
|
long discordId = Long.parseLong(discordAppealDto.getDiscordId());
|
||||||
|
Optional<BannedUser> join = discordAppealDiscord.getBannedUser(discordId).join();
|
||||||
if (join.isEmpty()) {
|
if (join.isEmpty()) {
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "User not found");
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "User not found");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ export class DiscordAppealComponent implements OnInit {
|
||||||
this.bannedUser = {
|
this.bannedUser = {
|
||||||
isBanned: false,
|
isBanned: false,
|
||||||
bannedUser: {
|
bannedUser: {
|
||||||
userId: 212303885988134914,
|
userId: '212303885988134914',
|
||||||
reason: "This is a test punishment",
|
reason: "This is a test punishment",
|
||||||
name: "stijn",
|
name: "stijn",
|
||||||
avatarUrl: "https://cdn.discordapp.com/avatars/212303885988134914/3a264be54ca7208d638a22143fc8fdb8.webp?size=160"
|
avatarUrl: "https://cdn.discordapp.com/avatars/212303885988134914/3a264be54ca7208d638a22143fc8fdb8.webp?size=160"
|
||||||
|
|
@ -145,7 +145,7 @@ export class DiscordAppealComponent implements OnInit {
|
||||||
this.nextPage();
|
this.nextPage();
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.appealService.getBannedUser(Number(this.discordId))
|
this.appealService.getBannedUser(this.discordId)
|
||||||
.subscribe(user => {
|
.subscribe(user => {
|
||||||
this.bannedUser = user
|
this.bannedUser = user
|
||||||
this.nextPage();
|
this.nextPage();
|
||||||
|
|
@ -178,7 +178,7 @@ export class DiscordAppealComponent implements OnInit {
|
||||||
throw new Error('JWT subject is null, are you logged in?');
|
throw new Error('JWT subject is null, are you logged in?');
|
||||||
}
|
}
|
||||||
const appeal: DiscordAppeal = {
|
const appeal: DiscordAppeal = {
|
||||||
discordId: Number(this.discordId),
|
discordId: this.discordId,
|
||||||
appeal: rawValue.appeal,
|
appeal: rawValue.appeal,
|
||||||
email: rawValue.email,
|
email: rawValue.email,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,9 +124,10 @@ components:
|
||||||
- email
|
- email
|
||||||
properties:
|
properties:
|
||||||
discordId:
|
discordId:
|
||||||
type: integer
|
type: string
|
||||||
format: int64
|
pattern: "^[0-9]{17,18}$"
|
||||||
description: Discord user's unique identifier'
|
minLength: 17
|
||||||
|
maxLength: 18
|
||||||
appeal:
|
appeal:
|
||||||
type: string
|
type: string
|
||||||
description: Appeal text explaining why the punishment should be reconsidered
|
description: Appeal text explaining why the punishment should be reconsidered
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,10 @@ getBannedUser:
|
||||||
required: true
|
required: true
|
||||||
description: The discord id of the user
|
description: The discord id of the user
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: string
|
||||||
format: int64
|
pattern: "^[0-9]{17,18}$"
|
||||||
|
minLength: 17
|
||||||
|
maxLength: 18
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Banned user
|
description: Banned user
|
||||||
|
|
@ -47,8 +49,10 @@ components:
|
||||||
- avatarUrl
|
- avatarUrl
|
||||||
properties:
|
properties:
|
||||||
userId:
|
userId:
|
||||||
type: integer
|
type: string
|
||||||
format: int64
|
pattern: "^[0-9]{17,18}$"
|
||||||
|
minLength: 17
|
||||||
|
maxLength: 18
|
||||||
reason:
|
reason:
|
||||||
type: string
|
type: string
|
||||||
name:
|
name:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user