Files
team/server/channels/app/cpa_value_audit.go
zeekay 8feb24ea1f One name for this fork, and it is ours
The server module named github.com/hanzoai/team/server/v8 — a path that
resolves to the retired workspace's repository, not this one — while
server/public still published github.com/mattermost/mattermost/server/public.
Both are github.com/hanzoteam/server/... now, which is where this code
actually lives.

That second half is what made the binary unbootable. Upstream's public path
stayed claimed by upstream, mattermost-plugin-ai imported it, and the build
linked public/model twice; public/plugin's gob.Register then ran twice under
one name and panicked at init, before main. Reverting the rename traded the
brand for a working binary. Rebranding the plugin alongside it needs no such
trade: the agents fork is github.com/hanzoteam/agents/v2 against our public
module, so no module named mattermost/mattermost is in the graph at all.

Measured: `go list -deps ./cmd/mattermost` names exactly one public/model, and
it is ours.
2026-08-28 23:35:36 -07:00

46 lines
1.6 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package app
import (
"github.com/hanzoteam/server/server/public/model"
"github.com/hanzoteam/server/server/public/shared/request"
"github.com/hanzoteam/server/server/v8/channels/app/properties"
)
// auditCPAValueChange emits one audit record for a successful CPA value change.
// It is the ValueAuditSink registered on PropertyValueAuditHook for the CPA
// group. Logged at the content audit level (data change).
func (a *App) auditCPAValueChange(rctx request.CTX, e properties.ValueAuditEvent) {
callerID, _ := CallerIDFromRequestContext(rctx)
scope := model.PropertyRequestOptionsFromContext(rctx.Context()).ActingAsScope
rec := a.MakeAuditRecord(rctx, model.AuditEventCPAValueChange, model.AuditStatusSuccess)
rec.AddMeta("caller_id", callerID)
rec.AddMeta("acting_as_scope", scope)
rec.AddMeta("group", model.AccessControlPropertyGroupName)
rec.AddMeta("action", e.Action)
rec.AddMeta("target_type", e.TargetType)
rec.AddMeta("target_id", e.TargetID)
if e.FieldID != "" {
rec.AddMeta("field_id", e.FieldID)
}
if e.ValueID != "" {
rec.AddMeta("value_id", e.ValueID)
}
switch e.Action {
case properties.ValueAuditActionDeleteForTarget, properties.ValueAuditActionDeleteForField:
// Bulk deletes have no per-value payload.
default:
if e.Prev != nil && len(e.Prev.Value) > 0 {
rec.AddMeta("prior_value", string(e.Prev.Value))
}
if e.Current != nil && len(e.Current.Value) > 0 {
rec.AddMeta("new_value", string(e.Current.Value))
}
}
a.LogAuditRecWithLevel(rctx, rec, LevelContent, nil)
}