Bump reva to 85468735db
To get new GetUserNoGroups() helper
This commit is contained in:
+1
-1
@@ -485,7 +485,7 @@ func (m *mgr) ListReceivedShares(ctx context.Context, filters []*collaboration.F
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to list shares")
|
||||
}
|
||||
u, err := utils.GetUser(forUser, gwc)
|
||||
u, err := utils.GetUser(ctx, forUser, gwc)
|
||||
if err != nil {
|
||||
return nil, errtypes.BadRequest("user not found")
|
||||
}
|
||||
|
||||
+1
-1
@@ -843,7 +843,7 @@ func (m *Manager) ListReceivedShares(ctx context.Context, filters []*collaborati
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
u, err := utils.GetUser(forUser, client)
|
||||
u, err := utils.GetUser(ctx, forUser, client)
|
||||
if err != nil {
|
||||
return nil, errtypes.BadRequest("user not found")
|
||||
}
|
||||
|
||||
Generated
Vendored
+3
-3
@@ -61,7 +61,7 @@ type DBShare struct {
|
||||
type UserConverter interface {
|
||||
UserNameToUserID(ctx context.Context, username string) (*userpb.UserId, error)
|
||||
UserIDToUserName(ctx context.Context, userid *userpb.UserId) (string, error)
|
||||
GetUser(userid *userpb.UserId) (*userpb.User, error)
|
||||
GetUser(ctx context.Context, userid *userpb.UserId) (*userpb.User, error)
|
||||
}
|
||||
|
||||
// GatewayUserConverter converts usernames and ids using the gateway
|
||||
@@ -140,12 +140,12 @@ func (c *GatewayUserConverter) UserNameToUserID(ctx context.Context, username st
|
||||
}
|
||||
|
||||
// GetUser gets the user
|
||||
func (c *GatewayUserConverter) GetUser(userid *userpb.UserId) (*userpb.User, error) {
|
||||
func (c *GatewayUserConverter) GetUser(ctx context.Context, userid *userpb.UserId) (*userpb.User, error) {
|
||||
gwc, err := pool.GetGatewayServiceClient(c.gwAddr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return utils.GetUser(userid, gwc)
|
||||
return utils.GetUser(ctx, userid, gwc)
|
||||
}
|
||||
|
||||
func (m *mgr) formatGrantee(ctx context.Context, g *provider.Grantee) (int, string, error) {
|
||||
|
||||
Generated
Vendored
+1
-1
@@ -339,7 +339,7 @@ func (m *mgr) ListShares(ctx context.Context, filters []*collaboration.Filter) (
|
||||
func (m *mgr) ListReceivedShares(ctx context.Context, filters []*collaboration.Filter, forUser *userpb.UserId) ([]*collaboration.ReceivedShare, error) {
|
||||
user := ctxpkg.ContextMustGetUser(ctx)
|
||||
if user.GetId().GetType() == userpb.UserType_USER_TYPE_SERVICE {
|
||||
u, err := m.userConverter.GetUser(forUser)
|
||||
u, err := m.userConverter.GetUser(ctx, forUser)
|
||||
if err != nil {
|
||||
return nil, errtypes.BadRequest("user not found")
|
||||
}
|
||||
|
||||
+13
-6
@@ -71,14 +71,21 @@ func GetServiceUserToken(ctx context.Context, gwc gateway.GatewayAPIClient, serv
|
||||
}
|
||||
|
||||
// GetUser gets the specified user
|
||||
// Deprecated: Use GetUserWithContext()
|
||||
func GetUser(userID *user.UserId, gwc gateway.GatewayAPIClient) (*user.User, error) {
|
||||
return GetUserWithContext(context.Background(), userID, gwc)
|
||||
func GetUser(ctx context.Context, userID *user.UserId, gwc gateway.GatewayAPIClient) (*user.User, error) {
|
||||
return getUser(ctx, userID, false, gwc)
|
||||
}
|
||||
|
||||
// GetUserWithContext gets the specified user
|
||||
func GetUserWithContext(ctx context.Context, userID *user.UserId, gwc gateway.GatewayAPIClient) (*user.User, error) {
|
||||
getUserResponse, err := gwc.GetUser(ctx, &user.GetUserRequest{UserId: userID})
|
||||
// GetUserNoGroups gets the specified user without expanding groupmemberships
|
||||
func GetUserNoGroups(ctx context.Context, userID *user.UserId, gwc gateway.GatewayAPIClient) (*user.User, error) {
|
||||
return getUser(ctx, userID, true, gwc)
|
||||
}
|
||||
|
||||
// getUser gets the specified user
|
||||
func getUser(ctx context.Context, userID *user.UserId, skipGroups bool, gwc gateway.GatewayAPIClient) (*user.User, error) {
|
||||
getUserResponse, err := gwc.GetUser(ctx, &user.GetUserRequest{
|
||||
UserId: userID,
|
||||
SkipFetchingUserGroups: skipGroups,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user