Fix the shared lists pseudo namespace containing owned lists

This commit is contained in:
kolaente 2021-01-31 13:09:14 +01:00
parent 6bdc1fdb0d
commit 2d283b78c2
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
3 changed files with 21 additions and 5 deletions

View file

@ -46,3 +46,9 @@
right: 2
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12
- id: 8
team_id: 1
list_id: 21
right: 0
updated: 2018-12-02 15:13:12
created: 2018-12-01 15:13:12

View file

@ -332,8 +332,14 @@ func (n *Namespace) ReadAll(s *xorm.Session, a web.Auth, search string, page int
Join("LEFT", []string{"team_list", "tl"}, "l.id = tl.list_id").
Join("LEFT", []string{"team_members", "tm"}, "tm.team_id = tl.team_id").
Join("LEFT", []string{"users_list", "ul"}, "ul.list_id = l.id").
Where("tm.user_id = ?", doer.ID).
Or("ul.user_id = ?", doer.ID).
Where(builder.And(
builder.Eq{"tm.user_id": doer.ID},
builder.Neq{"l.owner_id": doer.ID},
)).
Or(builder.And(
builder.Eq{"ul.user_id": doer.ID},
builder.Neq{"l.owner_id": doer.ID},
)).
GroupBy("l.id")
if !n.IsArchived {
iListQuery.And("l.is_archived = false")

View file

@ -142,8 +142,11 @@ func TestTaskCollection_ReadAll(t *testing.T) {
label4,
},
RelatedTasks: map[RelationKind][]*Task{},
Created: time.Unix(1543626724, 0).In(loc),
Updated: time.Unix(1543626724, 0).In(loc),
Reminders: []time.Time{
time.Unix(1543626824, 0).In(loc),
},
Created: time.Unix(1543626724, 0).In(loc),
Updated: time.Unix(1543626724, 0).In(loc),
}
task3 := &Task{
ID: 3,
@ -883,6 +886,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
},
args: defaultArgs,
want: []*Task{
task2,
task27,
},
wantErr: false,