added deleteTeamInvite API method
This commit is contained in:
parent
80510eb467
commit
ac15616e22
@ -685,7 +685,7 @@ public class Controller {
|
|||||||
|
|
||||||
Team team = (Team) getTeam.getBody();
|
Team team = (Team) getTeam.getBody();
|
||||||
|
|
||||||
if(teamInviteRepository.findByUserAndTeam(invitedUser, team) != null) {
|
if (teamInviteRepository.findByUserAndTeam(invitedUser, team) != null) {
|
||||||
return ResponseEntity.status(400).body("The user is already invited to this team");
|
return ResponseEntity.status(400).body("The user is already invited to this team");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -735,7 +735,7 @@ public class Controller {
|
|||||||
@RequestMapping("/api/deleteTeamInvite")
|
@RequestMapping("/api/deleteTeamInvite")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity deleteTeamInvite(@RequestParam String token,
|
public ResponseEntity deleteTeamInvite(@RequestParam String token,
|
||||||
@RequestParam ) {
|
@RequestParam String teamInviteID) {
|
||||||
// verify user
|
// verify user
|
||||||
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
|
||||||
|
|
||||||
@ -743,16 +743,18 @@ public class Controller {
|
|||||||
return verifyToken;
|
return verifyToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
//get User
|
// get teaminvite
|
||||||
Claims claims = (Claims) verifyToken.getBody();
|
ResponseEntity getTeamInvite = FinderUtil.findTeamInviteByID(teamInviteID);
|
||||||
|
|
||||||
ResponseEntity getUser = FinderUtil.findUserFromClaim(claims);
|
if (getTeamInvite.getStatusCodeValue() != 200) {
|
||||||
|
return getTeamInvite;
|
||||||
if (getUser.getStatusCodeValue() != 200) {
|
|
||||||
return getUser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
User user = (User) getUser.getBody();
|
TeamInvite teamInvite = (TeamInvite) getTeamInvite.getBody();
|
||||||
|
|
||||||
|
teamInviteRepository.delete(teamInvite);
|
||||||
|
|
||||||
|
return ResponseEntity.status(200).body("OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/api/hello")
|
@RequestMapping("/api/hello")
|
||||||
|
|||||||
@ -31,6 +31,8 @@ public class FinderUtil {
|
|||||||
|
|
||||||
static User_InfoRepository user_infoRepository;
|
static User_InfoRepository user_infoRepository;
|
||||||
|
|
||||||
|
static TeamInviteRepository teamInviteRepository;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public void setCacheRepository(CacheRepository cacheRepository) {
|
public void setCacheRepository(CacheRepository cacheRepository) {
|
||||||
@ -72,6 +74,11 @@ public class FinderUtil {
|
|||||||
FinderUtil.user_infoRepository = user_infoRepository;
|
FinderUtil.user_infoRepository = user_infoRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setTeamInviteRepository(TeamInviteRepository teamInviteRepository) {
|
||||||
|
FinderUtil.teamInviteRepository = teamInviteRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static ResponseEntity findCacheById(String cacheID) {
|
public static ResponseEntity findCacheById(String cacheID) {
|
||||||
|
|
||||||
@ -161,4 +168,13 @@ public class FinderUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ResponseEntity findTeamInviteByID(String teamInviteID) {
|
||||||
|
Optional<TeamInvite> teamInviteOptional = teamInviteRepository.findById(Integer.valueOf(teamInviteID));
|
||||||
|
if (teamInviteOptional.isPresent()) {
|
||||||
|
return ResponseEntity.status(200).body(teamInviteOptional.get());
|
||||||
|
} else {
|
||||||
|
return ResponseEntity.status(404).body("Couldnt find User_Info " + teamInviteID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user