[GH-21565]-Add the request context and logger to all public methods in server/channels/app/audit.go (#25368)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5f8133254d
Коммит
29cd6177c0
@@ -105,6 +105,8 @@ func scheduleExportCmdF(command *cobra.Command, args []string) error {
|
||||
return errors.New("ERROR: The message export feature is not enabled")
|
||||
}
|
||||
|
||||
var rctx request.CTX = request.EmptyContext(a.Log())
|
||||
|
||||
// for now, format is hard-coded to actiance. In time, we'll have to support other formats and inject them into job data
|
||||
format, err := command.Flags().GetString("format")
|
||||
if err != nil {
|
||||
@@ -138,7 +140,6 @@ func scheduleExportCmdF(command *cobra.Command, args []string) error {
|
||||
defer cancel()
|
||||
}
|
||||
|
||||
var rctx request.CTX = request.EmptyContext(a.Log())
|
||||
rctx = rctx.WithContext(ctx)
|
||||
|
||||
job, err := messageExportI.StartSynchronizeJob(rctx, startTime)
|
||||
@@ -147,10 +148,10 @@ func scheduleExportCmdF(command *cobra.Command, args []string) error {
|
||||
} else {
|
||||
CommandPrettyPrintln("SUCCESS: Message export job complete")
|
||||
|
||||
auditRec := a.MakeAuditRecord("scheduleExport", audit.Success)
|
||||
auditRec := a.MakeAuditRecord(rctx, "scheduleExport", audit.Success)
|
||||
auditRec.AddMeta("format", format)
|
||||
auditRec.AddMeta("start", startTime)
|
||||
a.LogAuditRec(auditRec, nil)
|
||||
a.LogAuditRec(rctx, auditRec, nil)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -165,6 +166,8 @@ func buildExportCmdF(format string) func(command *cobra.Command, args []string)
|
||||
}
|
||||
defer a.Srv().Shutdown()
|
||||
|
||||
rctx := request.EmptyContext(a.Log())
|
||||
|
||||
startTime, err := command.Flags().GetInt64("exportFrom")
|
||||
if err != nil {
|
||||
return errors.New("exportFrom flag error")
|
||||
@@ -182,7 +185,7 @@ func buildExportCmdF(format string) func(command *cobra.Command, args []string)
|
||||
return errors.New("message export feature not available")
|
||||
}
|
||||
|
||||
warningsCount, appErr := a.MessageExport().RunExport(request.EmptyContext(a.Log()), format, startTime, limit)
|
||||
warningsCount, appErr := a.MessageExport().RunExport(rctx, format, startTime, limit)
|
||||
if appErr != nil {
|
||||
return appErr
|
||||
}
|
||||
@@ -196,10 +199,10 @@ func buildExportCmdF(format string) func(command *cobra.Command, args []string)
|
||||
}
|
||||
}
|
||||
|
||||
auditRec := a.MakeAuditRecord("buildExport", audit.Success)
|
||||
auditRec := a.MakeAuditRecord(rctx, "buildExport", audit.Success)
|
||||
auditRec.AddMeta("format", format)
|
||||
auditRec.AddMeta("start", startTime)
|
||||
a.LogAuditRec(auditRec, nil)
|
||||
a.LogAuditRec(rctx, auditRec, nil)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -212,6 +215,8 @@ func bulkExportCmdF(command *cobra.Command, args []string) error {
|
||||
}
|
||||
defer a.Srv().Shutdown()
|
||||
|
||||
rctx := request.EmptyContext(a.Log())
|
||||
|
||||
allTeams, err := command.Flags().GetBool("all-teams")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "all-teams flag error")
|
||||
@@ -250,15 +255,15 @@ func bulkExportCmdF(command *cobra.Command, args []string) error {
|
||||
opts.IncludeAttachments = attachments
|
||||
opts.CreateArchive = archive
|
||||
opts.IncludeArchivedChannels = withArchivedChannels
|
||||
if err := a.BulkExport(request.EmptyContext(a.Log()), fileWriter, filepath.Dir(outPath), nil /* nil job since it's spawned from CLI */, opts); err != nil {
|
||||
if err := a.BulkExport(rctx, fileWriter, filepath.Dir(outPath), nil /* nil job since it's spawned from CLI */, opts); err != nil {
|
||||
CommandPrintErrorln(err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
auditRec := a.MakeAuditRecord("bulkExport", audit.Success)
|
||||
auditRec := a.MakeAuditRecord(rctx, "bulkExport", audit.Success)
|
||||
auditRec.AddMeta("all_teams", allTeams)
|
||||
auditRec.AddMeta("file", args[0])
|
||||
a.LogAuditRec(auditRec, nil)
|
||||
a.LogAuditRec(rctx, auditRec, nil)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user