[GH-21565]-Add the request context and logger to all public methods in server/channels/app/audit.go (#25368)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5f8133254d
Коммит
29cd6177c0
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||
"github.com/mattermost/mattermost/server/public/utils"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/audit"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/store"
|
||||
@@ -24,7 +25,7 @@ var (
|
||||
LevelCLI = mlog.LvlAuditCLI
|
||||
)
|
||||
|
||||
func (a *App) GetAudits(userID string, limit int) (model.Audits, *model.AppError) {
|
||||
func (a *App) GetAudits(rctx request.CTX, userID string, limit int) (model.Audits, *model.AppError) {
|
||||
audits, err := a.Srv().Store().Audit().Get(userID, 0, limit)
|
||||
if err != nil {
|
||||
var outErr *store.ErrOutOfBounds
|
||||
@@ -38,7 +39,7 @@ func (a *App) GetAudits(userID string, limit int) (model.Audits, *model.AppError
|
||||
return audits, nil
|
||||
}
|
||||
|
||||
func (a *App) GetAuditsPage(userID string, page int, perPage int) (model.Audits, *model.AppError) {
|
||||
func (a *App) GetAuditsPage(rctx request.CTX, userID string, page int, perPage int) (model.Audits, *model.AppError) {
|
||||
audits, err := a.Srv().Store().Audit().Get(userID, page*perPage, perPage)
|
||||
if err != nil {
|
||||
var outErr *store.ErrOutOfBounds
|
||||
@@ -53,12 +54,12 @@ func (a *App) GetAuditsPage(userID string, page int, perPage int) (model.Audits,
|
||||
}
|
||||
|
||||
// LogAuditRec logs an audit record using default LvlAuditCLI.
|
||||
func (a *App) LogAuditRec(rec *audit.Record, err error) {
|
||||
a.LogAuditRecWithLevel(rec, mlog.LvlAuditCLI, err)
|
||||
func (a *App) LogAuditRec(rctx request.CTX, rec *audit.Record, err error) {
|
||||
a.LogAuditRecWithLevel(rctx, rec, mlog.LvlAuditCLI, err)
|
||||
}
|
||||
|
||||
// LogAuditRecWithLevel logs an audit record using specified Level.
|
||||
func (a *App) LogAuditRecWithLevel(rec *audit.Record, level mlog.Level, err error) {
|
||||
func (a *App) LogAuditRecWithLevel(rctx request.CTX, rec *audit.Record, level mlog.Level, err error) {
|
||||
if rec == nil {
|
||||
return
|
||||
}
|
||||
@@ -74,7 +75,7 @@ func (a *App) LogAuditRecWithLevel(rec *audit.Record, level mlog.Level, err erro
|
||||
}
|
||||
|
||||
// MakeAuditRecord creates a audit record pre-populated with defaults.
|
||||
func (a *App) MakeAuditRecord(event string, initialStatus string) *audit.Record {
|
||||
func (a *App) MakeAuditRecord(rctx request.CTX, event string, initialStatus string) *audit.Record {
|
||||
var userID string
|
||||
user, err := user.Current()
|
||||
if err == nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user