Fix #4312: team instance for <TEAM_ID> not found (#4431)

This commit is contained in:
Vivek Ratnavel Subramanian 2022-04-23 22:03:54 -07:00 committed by GitHub
parent 48d39b14ee
commit 2a51148eee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -504,7 +504,7 @@ public interface CollectionDAO {
@SqlUpdate(
"DELETE from entity_relationship WHERE (toId = :id AND toEntity = :entity) OR "
+ "(fromId = :id AND toEntity = :entity)")
+ "(fromId = :id AND fromEntity = :entity)")
int deleteAll(@Bind("id") String id, @Bind("entity") String entity);
}

View File

@ -214,7 +214,9 @@ public class UserRepository extends EntityRepository<User> {
/* Add all the teams that user belongs to User entity */
private List<EntityReference> getTeams(User user) throws IOException {
List<String> teamIds = findFrom(user.getId(), Entity.USER, Relationship.HAS, Entity.TEAM);
return EntityUtil.populateEntityReferences(teamIds, Entity.TEAM);
List<EntityReference> teams = EntityUtil.populateEntityReferences(teamIds, Entity.TEAM);
// return only the non-deleted teams
return teams.stream().filter((team) -> !team.getDeleted()).collect(Collectors.toList());
}
private void assignRoles(User user, List<EntityReference> roles) {