mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-05-09 17:48:20 +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)
|
||||
}
|
||||
|
||||
users, err := c.GetUsers(ctx, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Get Users: %w", err)
|
||||
// if no users where added then we can skip this
|
||||
var users []api.User
|
||||
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{}
|
||||
|
@ -207,12 +211,3 @@ func GeneratePermissionChanges(oldPermissions []api.Permission, changes []ShareO
|
|||
}
|
||||
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