mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-05-10 01:48:22 +00:00
only fetch users if nessesary
This commit is contained in:
parent
ac4788b357
commit
2a08213258
1 changed files with 7 additions and 12 deletions
|
@ -68,9 +68,13 @@ func ShareResource(ctx context.Context, c *api.Client, resourceID string, change
|
||||||
return fmt.Errorf("Simulate Share Resource: %w", err)
|
return fmt.Errorf("Simulate Share Resource: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
users, err := c.GetUsers(ctx, nil)
|
// if no users where added then we can skip this
|
||||||
if err != nil {
|
var users []api.User
|
||||||
return fmt.Errorf("Get Users: %w", err)
|
if len(simulationResult.Changes.Added) != 0 {
|
||||||
|
users, err = c.GetUsers(ctx, nil)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Get Users: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shareRequest.Secrets = []api.Secret{}
|
shareRequest.Secrets = []api.Secret{}
|
||||||
|
@ -207,12 +211,3 @@ func GeneratePermissionChanges(oldPermissions []api.Permission, changes []ShareO
|
||||||
}
|
}
|
||||||
return permissionChanges, nil
|
return permissionChanges, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPublicKeyByUserID(userID string, Users []api.User) (string, error) {
|
|
||||||
for _, user := range Users {
|
|
||||||
if user.ID == userID {
|
|
||||||
return user.GPGKey.ArmoredKey, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "", fmt.Errorf("Cannot Find Key for user id %v", userID)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue