Skip to content

Commit c79596d

Browse files
committed
Fixed query with an opaque parameter and slightly changed display string
1 parent ab47b90 commit c79596d

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

internal/http/services/owncloud/ocgraph/conversions.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,15 +552,32 @@ func (s *svc) getDisplayNameForOCMUser(ctx context.Context, userId *userpb.UserI
552552
return "Federated User"
553553
}
554554

555+
// Pass the current user as opaque parameter. It seems the getUserFilter in internal/grpc/services/ocminvitemanager/ocminvitemanager.og
556+
// is not able to return the current user and this way we can force it.
557+
// TODO(lopresti) here we want a GetRemoteUser CS3 API that only requires the invitee's id
558+
user := appctx.ContextMustGetUser(ctx)
559+
userFilter, err := utils.MarshalProtoV1ToJSON(user.Id)
560+
if err != nil {
561+
log.Error().Err(err).Msg("getDisplayNameForOCMUser: failed to marshal current user id to json")
562+
return "Federated User"
563+
}
564+
555565
remoteUserRes, err := gw.GetAcceptedUser(ctx, &invitepb.GetAcceptedUserRequest{
556566
RemoteUserId: userId,
567+
Opaque: &types.Opaque{
568+
Map: map[string]*types.OpaqueEntry{
569+
"user-filter": {
570+
Decoder: "json",
571+
Value: userFilter,
572+
},
573+
},
574+
},
557575
})
558576
if err != nil || remoteUserRes.Status.Code != rpcv1beta1.Code_CODE_OK {
559577
log.Error().Err(err).Any("response", remoteUserRes).Any("remoteUser", userId).Msg("failed to fetch OCM user")
560-
return "Federated User at " + userId.Idp
578+
return "Federated User"
561579
}
562580

563-
log.Debug().Any("remoteUser", remoteUserRes.RemoteUser).Msg("found OCM user")
564581
return remoteUserRes.RemoteUser.DisplayName
565582
}
566583

pkg/utils/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ func PrintOCMUserId(u *userpb.UserId) string {
442442
if len(opaque) > 10 {
443443
opaque = opaque[:8] + "..."
444444
}
445-
return opaque + " at " + u.Idp
445+
return opaque + " on " + u.Idp
446446
}
447447

448448
// Cast casts a value `v` to the value `to`.

0 commit comments

Comments
 (0)