diff --git a/acp/acp_local.go b/acp/acp_local.go index a8a0d32290..48543d51e1 100644 --- a/acp/acp_local.go +++ b/acp/acp_local.go @@ -254,9 +254,25 @@ func (l *ACPLocal) AddActorRelationship( ctx = auth.InjectPrincipal(ctx, principal) + var newActorRelationship *types.Relationship + if targetActor == "*" { + newActorRelationship = types.NewAllActorsRelationship( + resourceName, + objectID, + relation, + ) + } else { + newActorRelationship = types.NewActorRelationship( + resourceName, + objectID, + relation, + targetActor, + ) + } + setRelationshipRequest := types.SetRelationshipRequest{ PolicyId: policyID, - Relationship: types.NewActorRelationship(resourceName, objectID, relation, targetActor), + Relationship: newActorRelationship, CreationTime: creationTime, } diff --git a/acp/acp_source_hub.go b/acp/acp_source_hub.go index edd6008b63..67d3c1762a 100644 --- a/acp/acp_source_hub.go +++ b/acp/acp_source_hub.go @@ -273,18 +273,28 @@ func (a *acpSourceHub) AddActorRelationship( creationTime *protoTypes.Timestamp, ) (bool, error) { msgSet := sourcehub.MsgSet{} + + var newActorRelationship *acptypes.Relationship + if targetActor == "*" { + newActorRelationship = acptypes.NewAllActorsRelationship( + resourceName, + objectID, + relation, + ) + } else { + newActorRelationship = acptypes.NewActorRelationship( + resourceName, + objectID, + relation, + targetActor, + ) + } + cmdMapper := msgSet.WithBearerPolicyCmd(&acptypes.MsgBearerPolicyCmd{ - Creator: a.signer.GetAccAddress(), - BearerToken: requester.BearerToken, - PolicyId: policyID, - Cmd: acptypes.NewSetRelationshipCmd( - acptypes.NewActorRelationship( - resourceName, - objectID, - relation, - targetActor, - ), - ), + Creator: a.signer.GetAccAddress(), + BearerToken: requester.BearerToken, + PolicyId: policyID, + Cmd: acptypes.NewSetRelationshipCmd(newActorRelationship), CreationTime: creationTime, }) tx, err := a.txBuilder.Build(ctx, a.signer, &msgSet)