Skip to content

Commit

Permalink
fix for #378
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Mar 13, 2020
1 parent 479bc32 commit 41f9528
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
10 changes: 9 additions & 1 deletion server/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,15 @@ func (UsersObjMapper) FindSubs(id types.Uid, required, optional []string) ([]typ
if err != nil {
return nil, err
}
return append(usubs, tsubs...), nil

allSubs := append(usubs, tsubs...)
for i, _ := range allSubs {
// Indicate that the returned access modes are not 'N', but rather undefined.
allSubs[i].ModeGiven = types.ModeUnset
allSubs[i].ModeWant = types.ModeUnset
}

return allSubs, nil
}

// GetTopics load a list of user's subscriptions with Public field copied to subscription
Expand Down
22 changes: 14 additions & 8 deletions server/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -1670,8 +1670,7 @@ func (t *Topic) replyGetSub(sess *Session, asUid types.Uid, authLevel auth.Level
return errors.New("attempt to search by restricted tags")
}

// FIXME: normal FindSub should not return suspended users and topics.
// Only root should be able to find them.
// FIXME: allow root to find suspended users and topics.
subs, err = store.Users.FindSubs(asUid, req, opt)
if err != nil {
sess.queueOut(decodeStoreError(err, id, t.original(asUid), now, nil))
Expand Down Expand Up @@ -1819,13 +1818,20 @@ func (t *Topic) replyGetSub(sess *Session, asUid types.Uid, authLevel auth.Level
mts.Acs.Mode = (sub.ModeGiven & sub.ModeWant).String()
mts.Acs.Want = sub.ModeWant.String()
mts.Acs.Given = sub.ModeGiven.String()
} else if defacs := sub.GetDefaultAccess(); defacs != nil {
} else {
// Topic 'fnd'
switch authLevel {
case auth.LevelAnon:
mts.Acs.Mode = defacs.Anon.String()
case auth.LevelAuth, auth.LevelRoot:
mts.Acs.Mode = defacs.Auth.String()
// sub.ModeXXX may be defined by the plugin.
if sub.ModeGiven.IsDefined() && sub.ModeWant.IsDefined() {
mts.Acs.Mode = (sub.ModeGiven & sub.ModeWant).String()
mts.Acs.Want = sub.ModeWant.String()
mts.Acs.Given = sub.ModeGiven.String()
} else if defacs := sub.GetDefaultAccess(); defacs != nil {
switch authLevel {
case auth.LevelAnon:
mts.Acs.Mode = defacs.Anon.String()
case auth.LevelAuth, auth.LevelRoot:
mts.Acs.Mode = defacs.Auth.String()
}
}
}

Expand Down

0 comments on commit 41f9528

Please sign in to comment.