diff options
Diffstat (limited to 'vendor/github.com/mattermost/mattermost-server/v5/model/auditconv.go')
-rw-r--r-- | vendor/github.com/mattermost/mattermost-server/v5/model/auditconv.go | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/vendor/github.com/mattermost/mattermost-server/v5/model/auditconv.go b/vendor/github.com/mattermost/mattermost-server/v5/model/auditconv.go index 50af2880..b3cf6062 100644 --- a/vendor/github.com/mattermost/mattermost-server/v5/model/auditconv.go +++ b/vendor/github.com/mattermost/mattermost-server/v5/model/auditconv.go @@ -3,7 +3,9 @@ package model -import "github.com/francoispqt/gojay" +import ( + "github.com/francoispqt/gojay" +) // AuditModelTypeConv converts key model types to something better suited for audit output. func AuditModelTypeConv(val interface{}) (newVal interface{}, converted bool) { @@ -49,6 +51,8 @@ func AuditModelTypeConv(val interface{}) (newVal interface{}, converted bool) { return newAuditIncomingWebhook(v), true case *OutgoingWebhook: return newAuditOutgoingWebhook(v), true + case *RemoteCluster: + return newRemoteCluster(v), true } return val, false } @@ -665,3 +669,45 @@ func (h auditOutgoingWebhook) MarshalJSONObject(enc *gojay.Encoder) { func (h auditOutgoingWebhook) IsNil() bool { return false } + +type auditRemoteCluster struct { + RemoteId string + RemoteTeamId string + Name string + DisplayName string + SiteURL string + CreateAt int64 + LastPingAt int64 + CreatorId string +} + +// newRemoteCluster creates a simplified representation of RemoteCluster for output to audit log. +func newRemoteCluster(r *RemoteCluster) auditRemoteCluster { + var rc auditRemoteCluster + if r != nil { + rc.RemoteId = r.RemoteId + rc.RemoteTeamId = r.RemoteTeamId + rc.Name = r.Name + rc.DisplayName = r.DisplayName + rc.SiteURL = r.SiteURL + rc.CreateAt = r.CreateAt + rc.LastPingAt = r.LastPingAt + rc.CreatorId = r.CreatorId + } + return rc +} + +func (r auditRemoteCluster) MarshalJSONObject(enc *gojay.Encoder) { + enc.StringKey("remote_id", r.RemoteId) + enc.StringKey("remote_team_id", r.RemoteTeamId) + enc.StringKey("name", r.Name) + enc.StringKey("display_name", r.DisplayName) + enc.StringKey("site_url", r.SiteURL) + enc.Int64Key("create_at", r.CreateAt) + enc.Int64Key("last_ping_at", r.LastPingAt) + enc.StringKey("creator_id", r.CreatorId) +} + +func (r auditRemoteCluster) IsNil() bool { + return false +} |