Explicitly check if there are Ids before trying to get items by a list of Ids

This commit is contained in:
kolaente 2021-03-02 18:40:39 +01:00
parent 3999580fe6
commit 6de3d8b3a1
Signed by untrusted user who does not match committer: konrad
GPG key ID: F40E70337AB24C9B
10 changed files with 61 additions and 18 deletions

View file

@ -218,9 +218,11 @@ func getLabelsByTaskIDs(s *xorm.Session, opts *LabelByTaskIDsOptions) (ls []*lab
userids = append(userids, l.CreatedByID)
}
users := make(map[int64]*user.User)
err = s.In("id", userids).Find(&users)
if err != nil {
return nil, 0, 0, err
if len(userids) > 0 {
err = s.In("id", userids).Find(&users)
if err != nil {
return nil, 0, 0, err
}
}
// Obfuscate all user emails