Conversation
Disable player and expiration checks if the clan is marked as "open"
|
Related to FAForever/db#206 |
| @SneakyThrows | ||
| String generatePlayerInvitationToken(Player requester, int clanId) { | ||
| // Playerless invitation | ||
| return generatePlayerInvitationToken(requester, 0, int clanId); |
There was a problem hiding this comment.
ah, oops
but i dont even know if overloading is the right thing to do here
There was a problem hiding this comment.
Why can u not? And yeah overloading is fine
| @SneakyThrows | ||
| String generatePlayerInvitationToken(Player requester, int clanId) { | ||
| // Playerless invitation | ||
| return generatePlayerInvitationToken(requester, 0, int clanId); |
There was a problem hiding this comment.
Why can u not? And yeah overloading is fine
|
|
||
| @SneakyThrows | ||
| String generatePlayerInvitationToken(Player requester, int clanId) { | ||
| // Playerless invitation |
There was a problem hiding this comment.
Either java doc or remove. Or maybe generatePlayerInvitationTokenWithoutPlayer
|
|
||
| Player newMember = playerRepository.findById(newMemberId) | ||
| .orElseThrow(() -> new ApiException(new Error(ErrorCode.CLAN_GENERATE_LINK_PLAYER_NOT_FOUND, newMemberId))); | ||
| Player newMember = clan.getIsOpen() ? null : |
There was a problem hiding this comment.
What should happen if the clan is not open.?For me it seems like there should not be an invite link generated, if so please throw a custom ApiException
There was a problem hiding this comment.
I mean if newMember if null and expire is 0 that seems weird to me.
|
|
||
|
|
||
| if (player.getId() != newMember.getId()) { | ||
| if (!invitation.getClan().getIsOpen() && player.getId() != newMember.getId()) { |
There was a problem hiding this comment.
Throw a different custom ApiException with your own error here. Otherwise test will be missleading
| .orElseThrow(() -> new ProgrammingError("ClanMember does not exist: " + invitation.getNewMember().getId())); | ||
| Player newMember = clan.getIsOpen() ? null : | ||
| playerRepository.findById(invitation.getNewMember().getId()) | ||
| .orElseThrow(() -> new ProgrammingError("ClanMember does not exist: " + invitation.getNewMember().getId())); |
There was a problem hiding this comment.
Throw an ApiException always those are the ones with custom error codes and text to them
| instance.generatePlayerInvitationToken(requester, clan.getId()); | ||
|
|
||
| // What do i do with this?? | ||
| // Invitation result should be modified to accept null players but i have no IDE here so navigating is a pain |
There was a problem hiding this comment.
Get an IDE and remove this comment
|
|
||
| @Test | ||
| public void acceptPlayerOpenInvitationCannotExpire() throws IOException { | ||
| // Why is the clan passed nowhere here?? How do I make it not expire if the clan is open since no clan is passed as part of the test? |
There was a problem hiding this comment.
This is all stored in the token
|
This is less a real PR than a desperate cry for help from a java developer who is more experienced than me |
|
sorry did not read that out of the comment u wrote i thought u meant to do a real PR |
|
I would have said lets do discord+ team viewer and do it together but not sure if u are the biggest fan of that |
|
I do not agree on the general approach here. Generating fake invite tokens are not a good approach to solve this issue. |
Dont look at me like I know what I'm doing please