1
0
Fork 0
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:
McMatts 2018-03-30 12:54:15 +01:00
parent 527b02e8b3
commit c138716ff4

View file

@ -72,15 +72,15 @@ func (h *Handler) Get(w http.ResponseWriter, r *http.Request) {
return return
} }
ctx.Transaction, err = h.Runtime.Db.Beginx()
if err != nil {
response.WriteServerError(w, method, err)
h.Runtime.Log.Error(method, err)
return
}
// draft mode does not record document views // draft mode does not record document views
if document.Lifecycle == workflow.LifecycleLive { if document.Lifecycle == workflow.LifecycleLive {
ctx.Transaction, err = h.Runtime.Db.Beginx()
if err != nil {
response.WriteServerError(w, method, err)
h.Runtime.Log.Error(method, err)
return
}
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)