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

@ -45,4 +45,10 @@
list_id: 19 list_id: 19
right: 2 right: 2
updated: 2018-12-02 15:13:12 updated: 2018-12-02 15:13:12
created: 2018-12-01 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_list", "tl"}, "l.id = tl.list_id").
Join("LEFT", []string{"team_members", "tm"}, "tm.team_id = tl.team_id"). Join("LEFT", []string{"team_members", "tm"}, "tm.team_id = tl.team_id").
Join("LEFT", []string{"users_list", "ul"}, "ul.list_id = l.id"). Join("LEFT", []string{"users_list", "ul"}, "ul.list_id = l.id").
Where("tm.user_id = ?", doer.ID). Where(builder.And(
Or("ul.user_id = ?", doer.ID). 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") GroupBy("l.id")
if !n.IsArchived { if !n.IsArchived {
iListQuery.And("l.is_archived = false") iListQuery.And("l.is_archived = false")

View File

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