Skip to content

Commit d7128bb

Browse files
committed
Tag users that have left CERN and hide them when performing a search (i.e. when sharing)
1 parent 8f437b5 commit d7128bb

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

user/cache.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ func (m *manager) findCachedUsers(query string) ([]*userpb.User, error) {
127127
userMap := make(map[string]*userpb.User)
128128
for _, user := range userStrings {
129129
u := userpb.User{}
130-
if err = json.Unmarshal([]byte(user), &u); err == nil {
130+
// Only keep users that have no opaque "inactive" flag set (cf. parseAndCacheUser)
131+
if err = json.Unmarshal([]byte(user), &u); err == nil && (u.Opaque == nil || u.Opaque.Map["inactive"] == nil) {
131132
userMap[u.Id.OpaqueId] = &u
132133
}
133134
}

user/rest.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"time"
2929

3030
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
31+
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
3132
"github.com/cs3org/reva/v3"
3233
"github.com/cs3org/reva/v3/pkg/appctx"
3334
utils "github.com/cs3org/reva/v3/pkg/cbox/utils"
@@ -232,6 +233,17 @@ func (m *manager) parseAndCacheUser(ctx context.Context, i *Identity) (*userpb.U
232233
GidNumber: int64(i.GID),
233234
}
234235
u.Username = utils.FormatUserID(u.Id)
236+
if i.ActiveUser == false && u.Id.Type == userpb.UserType_USER_TYPE_PRIMARY {
237+
// keep track that this primary account is inactive, i.e. has left CERN
238+
u.Opaque = &types.Opaque{
239+
Map: map[string]*types.OpaqueEntry{
240+
"inactive": {
241+
Decoder: "plain",
242+
Value: []byte("yes"),
243+
},
244+
},
245+
}
246+
}
235247

236248
if err := m.cacheUserDetails(u); err != nil {
237249
log.Error().Err(err).Msg("rest: error caching user details")

0 commit comments

Comments
 (0)