Fix returning task attachments created by users

This commit is contained in:
kolaente 2021-04-07 12:11:33 +02:00
parent 1af4598400
commit 6cea0bb286
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 25 additions and 7 deletions

View File

@ -553,7 +553,7 @@ func TestLinkSharing(t *testing.T) {
rec, err := testHandlerTaskWriteCollection.testReadAllWithLinkShare(nil, nil)
assert.NoError(t, err)
assert.NotContains(t, rec.Body.String(), `task #2`)
assert.NotContains(t, rec.Body.String(), `task #3`)
assert.NotContains(t, rec.Body.String(), `task #3"`)
assert.NotContains(t, rec.Body.String(), `task #4`)
assert.NotContains(t, rec.Body.String(), `task #5`)
assert.NotContains(t, rec.Body.String(), `task #6`)

View File

@ -239,12 +239,9 @@ func getTaskAttachmentsByTaskIDs(s *xorm.Session, taskIDs []int64) (attachments
return
}
users := make(map[int64]*user.User)
if len(userIDs) > 0 {
err = s.In("id", userIDs).Find(&users)
if err != nil {
return
}
users, err := getUsersOrLinkSharesFromIDs(s, userIDs)
if err != nil {
return nil, err
}
// Obfuscate all user emails

View File

@ -59,6 +59,12 @@ func TestTaskCollection_ReadAll(t *testing.T) {
Created: testCreatedTime,
Updated: testUpdatedTime,
}
linkShareUser2 := &user.User{
ID: -2,
Name: "Link Share",
Created: testCreatedTime,
Updated: testUpdatedTime,
}
loc := config.GetTimeZone()
@ -124,6 +130,21 @@ func TestTaskCollection_ReadAll(t *testing.T) {
CreatedBy: user1,
Created: testCreatedTime,
},
{
ID: 3,
TaskID: 1,
FileID: 1,
CreatedByID: -2,
CreatedBy: linkShareUser2,
Created: testCreatedTime,
File: &files.File{
ID: 1,
Name: "test",
Size: 100,
Created: time.Unix(1570998791, 0).In(loc),
CreatedByID: 1,
},
},
},
Created: time.Unix(1543626724, 0).In(loc),
Updated: time.Unix(1543626724, 0).In(loc),