mirror of
https://github.com/documize/community.git
synced 2025-07-22 22:59:43 +02:00
Refactor document view activity recording
This commit is contained in:
parent
527b02e8b3
commit
c138716ff4
1 changed files with 9 additions and 9 deletions
|
@ -72,6 +72,8 @@ func (h *Handler) Get(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// draft mode does not record document views
|
||||||
|
if document.Lifecycle == workflow.LifecycleLive {
|
||||||
ctx.Transaction, err = h.Runtime.Db.Beginx()
|
ctx.Transaction, err = h.Runtime.Db.Beginx()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
response.WriteServerError(w, method, err)
|
response.WriteServerError(w, method, err)
|
||||||
|
@ -79,8 +81,6 @@ func (h *Handler) Get(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// draft mode does not record document views
|
|
||||||
if document.Lifecycle == workflow.LifecycleLive {
|
|
||||||
err = h.Store.Activity.RecordUserActivity(ctx, activity.UserActivity{
|
err = h.Store.Activity.RecordUserActivity(ctx, activity.UserActivity{
|
||||||
LabelID: document.LabelID,
|
LabelID: document.LabelID,
|
||||||
DocumentID: document.RefID,
|
DocumentID: document.RefID,
|
||||||
|
@ -91,9 +91,9 @@ func (h *Handler) Get(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx.Transaction.Rollback()
|
ctx.Transaction.Rollback()
|
||||||
h.Runtime.Log.Error(method, err)
|
h.Runtime.Log.Error(method, err)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ctx.Transaction.Commit()
|
ctx.Transaction.Commit()
|
||||||
|
}
|
||||||
|
|
||||||
h.Store.Audit.Record(ctx, audit.EventTypeDocumentView)
|
h.Store.Audit.Record(ctx, audit.EventTypeDocumentView)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue