[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.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
efb960a160
Коммит
aaa62a40ae
@@ -9,7 +9,6 @@ import (
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/audit"
|
||||
)
|
||||
|
||||
func (api *API) InitSharedChannels() {
|
||||
@@ -171,11 +170,11 @@ func inviteRemoteClusterToChannel(c *Context, w http.ResponseWriter, r *http.Req
|
||||
return
|
||||
}
|
||||
|
||||
auditRec := c.MakeAuditRecord("inviteRemoteClusterToChannel", audit.Fail)
|
||||
auditRec := c.MakeAuditRecord("inviteRemoteClusterToChannel", model.AuditStatusFail)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
audit.AddEventParameter(auditRec, "remote_id", c.Params.RemoteId)
|
||||
audit.AddEventParameter(auditRec, "channel_id", c.Params.ChannelId)
|
||||
audit.AddEventParameter(auditRec, "user_id", c.AppContext.Session().UserId)
|
||||
model.AddEventParameterToAuditRec(auditRec, "remote_id", c.Params.RemoteId)
|
||||
model.AddEventParameterToAuditRec(auditRec, "channel_id", c.Params.ChannelId)
|
||||
model.AddEventParameterToAuditRec(auditRec, "user_id", c.AppContext.Session().UserId)
|
||||
|
||||
if err := c.App.InviteRemoteToChannel(c.Params.ChannelId, c.Params.RemoteId, c.AppContext.Session().UserId, true); err != nil {
|
||||
if appErr, ok := err.(*model.AppError); ok {
|
||||
@@ -222,10 +221,10 @@ func uninviteRemoteClusterToChannel(c *Context, w http.ResponseWriter, r *http.R
|
||||
return
|
||||
}
|
||||
|
||||
auditRec := c.MakeAuditRecord("uninviteRemoteClusterToChannel", audit.Fail)
|
||||
auditRec := c.MakeAuditRecord("uninviteRemoteClusterToChannel", model.AuditStatusFail)
|
||||
defer c.LogAuditRec(auditRec)
|
||||
audit.AddEventParameter(auditRec, "remote_id", c.Params.RemoteId)
|
||||
audit.AddEventParameter(auditRec, "channel_id", c.Params.ChannelId)
|
||||
model.AddEventParameterToAuditRec(auditRec, "remote_id", c.Params.RemoteId)
|
||||
model.AddEventParameterToAuditRec(auditRec, "channel_id", c.Params.ChannelId)
|
||||
|
||||
hasRemote, err := c.App.HasRemote(c.Params.ChannelId, c.Params.RemoteId)
|
||||
if err != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user