mirror of
https://github.com/documize/community.git
synced 2025-07-24 15:49:44 +02:00
link persistence
This commit is contained in:
parent
4a17acce11
commit
c27de6bcab
11 changed files with 160 additions and 104 deletions
|
@ -20,6 +20,7 @@ import (
|
|||
|
||||
"github.com/documize/community/core/api/endpoint/models"
|
||||
"github.com/documize/community/core/api/entity"
|
||||
"github.com/documize/community/core/api/util"
|
||||
"github.com/documize/community/core/log"
|
||||
"github.com/documize/community/core/utility"
|
||||
)
|
||||
|
@ -286,6 +287,27 @@ func (p *Persister) UpdatePage(page entity.Page, refID, userID string, skipRevis
|
|||
//}
|
||||
//}
|
||||
|
||||
// fimnd any content links
|
||||
links := util.GetContentLinks(page.Body)
|
||||
|
||||
// delete previous content links for this page
|
||||
_, _ = p.DeleteSourceLinks(page.RefID)
|
||||
|
||||
// save latest content links for this page
|
||||
for _, link := range links {
|
||||
link.OrgID = p.Context.OrgID
|
||||
link.UserID = p.Context.UserID
|
||||
link.SourceID = page.RefID
|
||||
link.Orphan = false
|
||||
|
||||
err := p.AddContentLink(link)
|
||||
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Unable to insert content links for page %s", page.RefID), err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
p.Base.Audit(p.Context, "update-page", page.DocumentID, page.RefID)
|
||||
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue