feat(actions): allow getting metadata of organizations from user grants (#7782)

* feat(actions): allow getting metadata of (other) organizations from user grants

* docs add action example
This commit is contained in:
Livio Spring
2024-04-22 13:34:23 +02:00
committed by GitHub
parent 9d754d84b3
commit 74624018c2
7 changed files with 64 additions and 56 deletions

View File

@@ -246,24 +246,13 @@ func (p *Storage) getCustomAttributes(ctx context.Context, user *query.User, use
}
}),
actions.SetFields("grants", func(c *actions.FieldConfig) interface{} {
return object.UserGrantsFromQuery(c, userGrants)
return object.UserGrantsFromQuery(ctx, p.query, c, userGrants)
}),
),
actions.SetFields("org",
actions.SetFields("getMetadata", func(c *actions.FieldConfig) interface{} {
return func(goja.FunctionCall) goja.Value {
metadata, err := p.query.SearchOrgMetadata(
ctx,
true,
user.ResourceOwner,
&query.OrgMetadataSearchQueries{},
false,
)
if err != nil {
logging.WithError(err).Info("unable to get org metadata in action")
panic(err)
}
return object.OrgMetadataListFromQuery(c, metadata)
return object.GetOrganizationMetadata(ctx, p.query, c, user.ResourceOwner)
}
}),
),