1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 05:09:42 +02:00
documize/model/activity/activity.go

174 lines
4.7 KiB
Go
Raw Permalink Normal View History

2017-07-26 20:03:23 +01:00
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
package activity
import "time"
// UserActivity represents an activity undertaken by a user.
type UserActivity struct {
2018-01-19 11:36:38 +00:00
ID uint64 `json:"id"`
2017-07-26 20:03:23 +01:00
OrgID string `json:"orgId"`
UserID string `json:"userId"`
SpaceID string `json:"spaceId"`
2018-01-19 11:36:38 +00:00
DocumentID string `json:"documentId"`
2018-09-18 20:55:40 +01:00
SectionID string `json:"pageId"`
2017-07-26 20:03:23 +01:00
ActivityType Type `json:"activityType"`
2018-01-19 11:36:38 +00:00
SourceType SourceType `json:"sourceType"`
2018-03-30 17:03:18 +01:00
Metadata string `json:"metadata"`
2017-07-26 20:03:23 +01:00
Created time.Time `json:"created"`
2018-03-30 17:03:18 +01:00
// Read-only outbound fields (e.g. for UI display)
SourceName string `json:"sourceName"`
2017-07-26 20:03:23 +01:00
}
2018-01-19 11:36:38 +00:00
// DocumentActivity represents an activity taken against a document.
type DocumentActivity struct {
ID uint64 `json:"id"`
OrgID string `json:"orgId"`
SpaceID string `json:"spaceId"`
2018-01-19 11:36:38 +00:00
DocumentID string `json:"documentId"`
2018-09-18 20:55:40 +01:00
SectionID string `json:"pageId"`
SectionName string `json:"pageTitle"`
2018-01-19 11:36:38 +00:00
UserID string `json:"userId"`
Firstname string `json:"firstname"`
Lastname string `json:"lastname"`
ActivityType int `json:"activityType"`
Metadata string `json:"metadata"`
2018-01-19 11:36:38 +00:00
Created time.Time `json:"created"`
}
2017-07-26 20:03:23 +01:00
// SourceType details where the activity occured.
type SourceType int
// Type determines type of user activity
type Type int
const (
// SourceTypeSpace indicates activity against a space.
SourceTypeSpace SourceType = 1
// SourceTypeDocument indicates activity against a document.
SourceTypeDocument SourceType = 2
2018-01-10 16:07:17 +00:00
// SourceTypePage indicates activity against a document page.
SourceTypePage SourceType = 3
2018-03-30 17:03:18 +01:00
// SourceTypeSearch indicates activity on search page.
SourceTypeSearch SourceType = 4
2017-07-26 20:03:23 +01:00
)
const (
2018-03-30 17:03:18 +01:00
// TypeCreated records user object creation (document or space).
2017-07-26 20:03:23 +01:00
TypeCreated Type = 1
2018-03-30 17:03:18 +01:00
// TypeRead states user has consumed object (document or space).
2017-07-26 20:03:23 +01:00
TypeRead Type = 2
2018-03-30 17:03:18 +01:00
// TypeEdited states user has editing document.
2017-07-26 20:03:23 +01:00
TypeEdited Type = 3
2018-03-30 17:03:18 +01:00
// TypeDeleted records user deleting space/document.
2017-07-26 20:03:23 +01:00
TypeDeleted Type = 4
2018-03-30 17:03:18 +01:00
// TypeArchived records user archiving space/document.
2017-07-26 20:03:23 +01:00
TypeArchived Type = 5
2018-03-30 17:03:18 +01:00
// TypeApproved records user approval of document.
2017-07-26 20:03:23 +01:00
TypeApproved Type = 6
2018-03-30 17:03:18 +01:00
// TypeReverted records user content roll-back to previous document version.
2017-07-26 20:03:23 +01:00
TypeReverted Type = 7
2018-03-30 17:03:18 +01:00
// TypePublishedTemplate records user creating new document template.
2017-07-26 20:03:23 +01:00
TypePublishedTemplate Type = 8
2018-03-30 17:03:18 +01:00
// TypePublishedBlock records user creating reusable content block.
2017-07-26 20:03:23 +01:00
TypePublishedBlock Type = 9
2018-03-30 17:03:18 +01:00
// TypeCommented records user providing document feedback.
2018-01-19 11:36:38 +00:00
TypeCommented Type = 10
2018-01-10 16:07:17 +00:00
2018-03-30 17:03:18 +01:00
// TypeRejected records user rejecting document.
2018-01-10 16:07:17 +00:00
TypeRejected Type = 11
2018-01-19 11:36:38 +00:00
2018-03-30 17:03:18 +01:00
// TypeSentSecureLink records user sending secure document link via email.
2018-01-19 11:36:38 +00:00
TypeSentSecureLink Type = 12
2018-03-16 18:27:33 +00:00
2018-03-30 17:03:18 +01:00
// TypeDraft records user marking space/document as draft.
2018-03-16 18:27:33 +00:00
TypeDraft Type = 13
2018-03-19 13:01:53 +00:00
2018-03-30 17:03:18 +01:00
// TypeVersioned records user creating new document version.
2018-03-19 13:01:53 +00:00
TypeVersioned Type = 14
2018-03-30 17:03:18 +01:00
// TypeSearched records user performing document keyword search.
// Metadata field should contain search terms.
TypeSearched Type = 15
// TypePublished happens when a document is moved from Draft to Live.
TypePublished Type = 16
// TypePinned happens when a document is pinned within space.
TypePinned Type = 17
// TypeUnpinned happens when a document is no longer pinned inside a space.
TypeUnpinned Type = 18
// TypePinSequence is when the order of sequenced documents is changed.
TypePinSequence Type = 19
2017-07-26 20:03:23 +01:00
)
2018-01-19 11:36:38 +00:00
// TypeName returns one-work descriptor for activity type
func TypeName(t Type) string {
switch t {
case TypeCreated:
return "Add"
case TypeRead:
return "View"
case TypeEdited:
return "Edit"
case TypeDeleted:
return "Delete"
case TypeArchived:
return "Archive"
case TypeApproved:
return "Approve"
case TypeReverted:
return "Revert"
case TypePublishedTemplate:
return "Publish"
case TypePublishedBlock:
return "Publish"
case TypeCommented:
return "Comment"
case TypeRejected:
return "Reject"
case TypeSentSecureLink:
return "Share"
2018-03-30 17:03:18 +01:00
case TypeDraft:
return "Draft"
case TypeVersioned:
return "Version"
case TypeSearched:
return "Search"
case TypePublished:
return "Publish"
case TypePinned:
return "Pinned"
case TypeUnpinned:
return "Unpinned"
case TypePinSequence:
return "Sequence"
2018-01-19 11:36:38 +00:00
}
return ""
}