Add copying link shares

This commit is contained in:
kolaente 2020-06-30 16:57:42 +02:00
parent 0bfbc1082b
commit babce6a327
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 15 additions and 0 deletions

View File

@ -18,6 +18,7 @@ package models
import (
"code.vikunja.io/api/pkg/files"
"code.vikunja.io/api/pkg/utils"
"code.vikunja.io/web"
)
@ -254,5 +255,19 @@ func (ld *ListDuplicate) Create(a web.Auth) (err error) {
}
// Generate new link shares if any are available
linkShares := []*LinkSharing{}
err = x.Where("list_id = ?", ld.ListID).Find(&linkShares)
if err != nil {
return
}
for _, share := range linkShares {
share.ID = 0
share.ListID = ld.List.ID
share.Hash = utils.MakeRandomString(40)
if _, err := x.Insert(share); err != nil {
return err
}
}
return
}