[MM-64686] Expose audit logging functionality via plugin API (#31204)

This commit exposes audit logging functionality to plugins via the plugin API, allowing plugins to create and log audit records. Additionally, it addresses a gob encoding issue that could cause plugin crashes when audit data contains nil pointers or unregistered types.
Этот коммит содержится в:
David Krauser
2025-06-25 20:37:32 -04:00
коммит произвёл GitHub
родитель efb960a160
Коммит aaa62a40ae
68 изменённых файлов: 878 добавлений и 750 удалений

Просмотреть файл

@@ -6,8 +6,8 @@ package api4
import (
"net/http"
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/v8/channels/app"
"github.com/mattermost/mattermost/server/v8/channels/audit"
)
func (api *API) InitPostLocal() {
@@ -24,10 +24,10 @@ func localDeletePost(c *Context, w http.ResponseWriter, r *http.Request) {
permanent := c.Params.Permanent
auditRec := c.MakeAuditRecord("localDeletePost", audit.Fail)
auditRec := c.MakeAuditRecord("localDeletePost", model.AuditStatusFail)
defer c.LogAuditRecWithLevel(auditRec, app.LevelContent)
audit.AddEventParameter(auditRec, "post_id", c.Params.PostId)
audit.AddEventParameter(auditRec, "permanent", permanent)
model.AddEventParameterToAuditRec(auditRec, "post_id", c.Params.PostId)
model.AddEventParameterToAuditRec(auditRec, "permanent", permanent)
includeDeleted := permanent