diff --git a/domain/document/store.go b/domain/document/store.go index 39bb8fbe..17c1ef05 100644 --- a/domain/document/store.go +++ b/domain/document/store.go @@ -179,6 +179,18 @@ func (s Store) Update(ctx domain.RequestContext, document doc.Document) (err err return } +// UpdateRevised sets document revision date to UTC now. +func (s Store) UpdateRevised(ctx domain.RequestContext, docID string) (err error) { + _, err = ctx.Transaction.Exec(s.Bind(`UPDATE dmz_doc SET c_revised=? WHERE c_orgid=? AND c_refid=?`), + time.Now().UTC(), ctx.OrgID, docID) + + if err != nil { + err = errors.Wrap(err, "document.store.UpdateRevised") + } + + return +} + // UpdateGroup applies same values to all documents with the same group ID. func (s Store) UpdateGroup(ctx domain.RequestContext, d doc.Document) (err error) { _, err = ctx.Transaction.Exec(s.Bind(`UPDATE dmz_doc SET c_name=?, c_desc=? WHERE c_orgid=? AND c_groupid=?`), diff --git a/domain/page/endpoint.go b/domain/page/endpoint.go index f93523ae..3d2afb76 100644 --- a/domain/page/endpoint.go +++ b/domain/page/endpoint.go @@ -175,6 +175,9 @@ func (h *Handler) Add(w http.ResponseWriter, r *http.Request) { ActivityType: activity.TypeCreated}) } + // Update doc revised. + h.Store.Document.UpdateRevised(ctx, doc.RefID) + ctx.Transaction.Commit() h.Store.Audit.Record(ctx, audit.EventTypeSectionAdd) @@ -492,6 +495,9 @@ func (h *Handler) Update(w http.ResponseWriter, r *http.Request) { } } + // Update doc revised. + h.Store.Document.UpdateRevised(ctx, model.Page.DocumentID) + ctx.Transaction.Commit() if doc.Lifecycle == workflow.LifecycleLive { @@ -593,6 +599,9 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) { h.Store.Page.DeletePageRevisions(ctx, pageID) + // Update doc revised. + h.Store.Document.UpdateRevised(ctx, doc.RefID) + ctx.Transaction.Commit() h.Store.Audit.Record(ctx, audit.EventTypeSectionDelete) @@ -702,6 +711,9 @@ func (h *Handler) DeletePages(w http.ResponseWriter, r *http.Request) { } } + // Update doc revised. + h.Store.Document.UpdateRevised(ctx, doc.RefID) + ctx.Transaction.Commit() h.Store.Audit.Record(ctx, audit.EventTypeSectionDelete) @@ -779,6 +791,9 @@ func (h *Handler) ChangePageSequence(w http.ResponseWriter, r *http.Request) { } } + // Update doc revised. + h.Store.Document.UpdateRevised(ctx, doc.RefID) + ctx.Transaction.Commit() h.Store.Audit.Record(ctx, audit.EventTypeSectionResequence) @@ -848,6 +863,9 @@ func (h *Handler) ChangePageLevel(w http.ResponseWriter, r *http.Request) { } } + // Update doc revised. + h.Store.Document.UpdateRevised(ctx, doc.RefID) + ctx.Transaction.Commit() h.Store.Audit.Record(ctx, audit.EventTypeSectionResequence) @@ -969,6 +987,9 @@ func (h *Handler) Copy(w http.ResponseWriter, r *http.Request) { ActivityType: activity.TypeCreated}) } + // Update doc revised. + h.Store.Document.UpdateRevised(ctx, targetID) + ctx.Transaction.Commit() h.Store.Audit.Record(ctx, audit.EventTypeSectionCopy) @@ -1223,6 +1244,9 @@ func (h *Handler) Rollback(w http.ResponseWriter, r *http.Request) { ActivityType: activity.TypeReverted}) } + // Update doc revised. + h.Store.Document.UpdateRevised(ctx, doc.RefID) + ctx.Transaction.Commit() h.Store.Audit.Record(ctx, audit.EventTypeSectionRollback)