Skip to content

Fixed organizationByEmail endpoint #1647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,23 @@ public Mono<PageResponseView<?>> getOrganizationByUser(@PathVariable String emai
@RequestParam(required = false, defaultValue = "0") Integer pageSize) {
Flux<OrgView> flux;
if (commonConfig.getWorkspace().getMode() == WorkspaceMode.SAAS) {
flux = userService.findByEmailDeep(email).flux().flatMap(user -> orgMemberService.getAllActiveOrgs(user.getId()))
flux = userService.findByEmailDeep(email).flux()
.flatMap(user -> orgMemberService.getAllActiveOrgs(user.getId()))
.flatMap(orgMember -> organizationService.getById(orgMember.getOrgId()))
.map(OrgView::new).cache();
.map(OrgView::new)
.cache();
} else {
flux = organizationService.getOrganizationInEnterpriseMode().flux().map(OrgView::new).cache();
// Not SAAS: check if user exists and is a member of the org
flux = userService.findByEmailDeep(email)
.flatMapMany(user ->
organizationService.getOrganizationInEnterpriseMode().flux()
.flatMap(org ->
orgMemberService.getOrgMember(org.getId(), user.getId())
.filter(orgMember -> !orgMember.isInvalid())
.map(__ -> new OrgView(org))
)
)
.cache();
}
var newflux = flux.sort((OrgView o1, OrgView o2) -> {
if (o1.getOrgName() == null || o2.getOrgName() == null) {
Expand Down
Loading