mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(organizations): attach the tags passed to InviteAccountToOrganization (#8048)
This commit is contained in:
1 parent
a27670c4bb
commit
162401b942
8 files changed
+59
-9
No files matched your search
@@ -588,7 +588,8 @@ public class OrganizationsJsonHandler {
|
||||
private Response inviteAccountToOrganization(JsonNode request, String caller) {
|
||||
JsonNode target = request.path("Target");
|
||||
Handshake handshake = service.inviteAccountToOrganization(caller,
|
||||
text(target, "Id"), text(target, "Type"), text(request, "Notes"));
|
||||
text(target, "Id"), text(target, "Type"), text(request, "Notes"),
|
||||
parseTags(request.path("Tags")));
|
||||
return handshakeResponse(handshake);
|
||||
}
|
||||
|
||||
|
||||
@@ -1289,7 +1289,7 @@ public class OrganizationsService implements ScpProvider, RootAccessOrganization
|
||||
// ──────────────────────────── Handshakes ────────────────────────────
|
||||
|
||||
public Handshake inviteAccountToOrganization(String callerAccountId, String targetId, String targetType,
|
||||
String notes) {
|
||||
String notes, Map<String, String> tags) {
|
||||
Organization organization = requireManagementAccount(callerAccountId);
|
||||
if (targetId == null || targetId.isEmpty()) {
|
||||
throw invalidInput("Target.Id is required.");
|
||||
@@ -1298,6 +1298,7 @@ public class OrganizationsService implements ScpProvider, RootAccessOrganization
|
||||
if (!"ACCOUNT".equals(resolvedType) && !"EMAIL".equals(resolvedType)) {
|
||||
throw invalidInput("Target.Type must be ACCOUNT or EMAIL.");
|
||||
}
|
||||
validateTags(tags);
|
||||
|
||||
String invitedAccountId = null;
|
||||
String invitedEmail = null;
|
||||
@@ -1334,6 +1335,9 @@ public class OrganizationsService implements ScpProvider, RootAccessOrganization
|
||||
Handshake handshake = newHandshake(organization, HANDSHAKE_INVITE);
|
||||
handshake.setTargetAccountId(invitedAccountId);
|
||||
handshake.setTargetEmail(invitedEmail);
|
||||
if (tags != null) {
|
||||
handshake.getTags().putAll(tags);
|
||||
}
|
||||
handshake.getParties().add(new HandshakeParty(organization.getId(), "ORGANIZATION"));
|
||||
handshake.getParties().add(new HandshakeParty(targetId, resolvedType));
|
||||
|
||||
@@ -1378,6 +1382,7 @@ public class OrganizationsService implements ScpProvider, RootAccessOrganization
|
||||
: "account-" + callerAccountId + "@example.com";
|
||||
OrganizationAccount account = newMemberAccount(
|
||||
organization, callerAccountId, email, "invited-" + callerAccountId, "INVITED");
|
||||
account.getTags().putAll(handshake.getTags());
|
||||
accounts.putForAccount(organization.getMasterAccountId(), callerAccountId, account);
|
||||
attachFullAwsAccess(organization, callerAccountId);
|
||||
handshake.setTargetAccountId(callerAccountId);
|
||||
|
||||
@@ -4,7 +4,9 @@ import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Domain model for a handshake — the two-party exchange behind
|
||||
@@ -13,6 +15,8 @@ import java.util.List;
|
||||
* <p>{@code targetAccountId} and {@code targetEmail} are Floci bookkeeping, not part of the
|
||||
* AWS wire shape: they record which account (or email) the invitation was addressed to so
|
||||
* {@code ListHandshakesForAccount} can answer for a caller that has not joined yet.
|
||||
* {@code tags} is bookkeeping too: the invitation's tags, attached to the account when it
|
||||
* accepts.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
public class Handshake {
|
||||
@@ -28,6 +32,7 @@ public class Handshake {
|
||||
private String organizationId;
|
||||
private String targetAccountId;
|
||||
private String targetEmail;
|
||||
private Map<String, String> tags = new LinkedHashMap<>();
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
@@ -116,4 +121,12 @@ public class Handshake {
|
||||
public void setTargetEmail(String targetEmail) {
|
||||
this.targetEmail = targetEmail;
|
||||
}
|
||||
|
||||
public Map<String, String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(Map<String, String> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user