1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-24 07:39:43 +02:00

document activity log

This commit is contained in:
Harvey Kandola 2017-04-04 17:55:17 +01:00
parent d91811bb3d
commit 96e4b2058c
9 changed files with 182 additions and 96 deletions

View file

@ -26,6 +26,7 @@ import (
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
"github.com/documize/community/core/api/util"
"github.com/gorilla/mux"
)
@ -126,39 +127,25 @@ func GetDocument(w http.ResponseWriter, r *http.Request) {
writeSuccessBytes(w, json)
}
// GetDocumentMeta is an endpoint returning the metadata for a document.
func GetDocumentMeta(w http.ResponseWriter, r *http.Request) {
method := "GetDocumentMeta"
// GetDocumentActivity is an endpoint returning the activity logs for specified document.
func GetDocumentActivity(w http.ResponseWriter, r *http.Request) {
method := "GetDocumentActivity"
p := request.GetPersister(r)
params := mux.Vars(r)
id := params["documentID"]
id := params["documentID"]
if len(id) == 0 {
writeMissingDataError(w, method, "documentID")
return
}
meta, err := p.GetDocumentMeta(id)
if err == sql.ErrNoRows {
writeNotFoundError(w, method, id)
return
}
if err != nil {
a, err := p.GetDocumentActivity(id)
if err != nil && err != sql.ErrNoRows {
writeGeneralSQLError(w, method, err)
return
}
json, err := json.Marshal(meta)
if err != nil {
writeJSONMarshalError(w, method, "document", err)
return
}
writeSuccessBytes(w, json)
util.WriteJSON(w, a)
}
// GetDocumentLinks is an endpoint returning the links for a document.

View file

@ -16,6 +16,7 @@ package models
import (
"github.com/documize/community/core/api/entity"
"time"
)
// PageSequenceRequestModel details a page ID and its sequence within the document.
@ -66,3 +67,16 @@ type PageModel struct {
Page entity.Page `json:"page"`
Meta entity.PageMeta `json:"meta"`
}
// DocumentActivity represents an activity taken against a document.
type DocumentActivity struct {
ID int `json:"id"`
OrgID string `json:"orgId"`
LabelID string `json:"folderId"`
DocumentID string `json:"documentId"`
UserID string `json:"userId"`
Firstname string `json:"firstname"`
Lastname string `json:"lastname"`
ActivityType int `json:"activityType"`
Created time.Time `json:"created"`
}

View file

@ -155,7 +155,7 @@ func init() {
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}", []string{"GET", "OPTIONS"}, nil, GetDocument))
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}", []string{"PUT", "OPTIONS"}, nil, UpdateDocument))
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}", []string{"DELETE", "OPTIONS"}, nil, DeleteDocument))
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/meta", []string{"GET", "OPTIONS"}, nil, GetDocumentMeta))
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/activity", []string{"GET", "OPTIONS"}, nil, GetDocumentActivity))
// Document Page
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages/level", []string{"POST", "OPTIONS"}, nil, ChangeDocumentPageLevel))