Skip to content

Commit

Permalink
PR: Do the fix with "*"
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzadlone committed Nov 18, 2024
1 parent d8180e1 commit c315bcd
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
18 changes: 17 additions & 1 deletion acp/acp_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
32 changes: 21 additions & 11 deletions acp/acp_source_hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c315bcd

Please sign in to comment.