Add copying list shares

This commit is contained in:
kolaente 2020-06-30 16:55:36 +02:00
parent 2089fd3da3
commit 0bfbc1082b
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 26 additions and 0 deletions

View File

@ -227,6 +227,32 @@ func (ld *ListDuplicate) Create(a web.Auth) (err error) {
}
// Rights / Shares
// To keep it simple(r) we will only copy rights which are directly used with the list, no namespace changes.
users := []*ListUser{}
err = x.Where("list_id = ?", ld.ListID).Find(&users)
if err != nil {
return
}
for _, u := range users {
u.ID = 0
u.ListID = ld.List.ID
if _, err := x.Insert(u); err != nil {
return err
}
}
teams := []*TeamList{}
err = x.Where("list_id = ?", ld.ListID).Find(&teams)
if err != nil {
return
}
for _, t := range teams {
t.ID = 0
t.ListID = ld.List.ID
if _, err := x.Insert(t); err != nil {
return err
}
}
// Generate new link shares if any are available
return
}