SystemStore migration to return plain errors (#14835)
* SystemStore migration to return plain errors * Fix nilness * Fix translations * Fix merge * Fix layers * Fix merge errors * Lint: remove unnecessary use of sprint * Fix merge errors * Fix i18n Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e8d431ee7c
Коммит
20e44399c7
26
app/app.go
26
app/app.go
@@ -154,9 +154,9 @@ func (a *App) Handle404(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (s *Server) getSystemInstallDate() (int64, *model.AppError) {
|
||||
systemData, appErr := s.Store.System().GetByName(model.SYSTEM_INSTALLATION_DATE_KEY)
|
||||
if appErr != nil {
|
||||
return 0, appErr
|
||||
systemData, err := s.Store.System().GetByName(model.SYSTEM_INSTALLATION_DATE_KEY)
|
||||
if err != nil {
|
||||
return 0, model.NewAppError("getSystemInstallDate", "app.system.get_by_name.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
value, err := strconv.ParseInt(systemData.Value, 10, 64)
|
||||
if err != nil {
|
||||
@@ -166,9 +166,9 @@ func (s *Server) getSystemInstallDate() (int64, *model.AppError) {
|
||||
}
|
||||
|
||||
func (s *Server) getFirstServerRunTimestamp() (int64, *model.AppError) {
|
||||
systemData, appErr := s.Store.System().GetByName(model.SYSTEM_FIRST_SERVER_RUN_TIMESTAMP_KEY)
|
||||
if appErr != nil {
|
||||
return 0, appErr
|
||||
systemData, err := s.Store.System().GetByName(model.SYSTEM_FIRST_SERVER_RUN_TIMESTAMP_KEY)
|
||||
if err != nil {
|
||||
return 0, model.NewAppError("getFirstServerRunTimestamp", "app.system.get_by_name.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
value, err := strconv.ParseInt(systemData.Value, 10, 64)
|
||||
if err != nil {
|
||||
@@ -178,9 +178,9 @@ func (s *Server) getFirstServerRunTimestamp() (int64, *model.AppError) {
|
||||
}
|
||||
|
||||
func (a *App) GetWarnMetricsStatus() (map[string]*model.WarnMetricStatus, *model.AppError) {
|
||||
systemDataList, appErr := a.Srv().Store.System().Get()
|
||||
if appErr != nil {
|
||||
return nil, appErr
|
||||
systemDataList, nErr := a.Srv().Store.System().Get()
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("GetWarnMetricsStatus", "app.system.get.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
result := map[string]*model.WarnMetricStatus{}
|
||||
@@ -345,8 +345,8 @@ func (a *App) notifyAdminsOfWarnMetricStatus(warnMetricId string) *model.AppErro
|
||||
|
||||
func (a *App) NotifyAndSetWarnMetricAck(warnMetricId string, sender *model.User, forceAck bool, isBot bool) *model.AppError {
|
||||
if warnMetric, ok := model.WarnMetricsTable[warnMetricId]; ok {
|
||||
data, err := a.Srv().Store.System().GetByName(warnMetric.Id)
|
||||
if err == nil && data != nil && data.Value == model.WARN_METRIC_STATUS_ACK {
|
||||
data, nErr := a.Srv().Store.System().GetByName(warnMetric.Id)
|
||||
if nErr == nil && data != nil && data.Value == model.WARN_METRIC_STATUS_ACK {
|
||||
mlog.Debug("This metric warning has already been acknowledged")
|
||||
return nil
|
||||
}
|
||||
@@ -384,14 +384,14 @@ func (a *App) NotifyAndSetWarnMetricAck(warnMetricId string, sender *model.User,
|
||||
subject := T("api.templates.warn_metric_ack.subject")
|
||||
bodyPage.Props["Title"] = warnMetricDisplayTexts.EmailBody
|
||||
|
||||
if err = mailservice.SendMailUsingConfig(model.MM_SUPPORT_ADDRESS, subject, bodyPage.Render(), a.Config(), false, sender.Email); err != nil {
|
||||
if err := mailservice.SendMailUsingConfig(model.MM_SUPPORT_ADDRESS, subject, bodyPage.Render(), a.Config(), false, sender.Email); err != nil {
|
||||
mlog.Error("Error while sending email", mlog.String("destination email", model.MM_SUPPORT_ADDRESS), mlog.Err(err))
|
||||
return model.NewAppError("NotifyAndSetWarnMetricAck", "api.email.send_warn_metric_ack.failure.app_error", map[string]interface{}{"Error": err.Error()}, "", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
mlog.Debug("Disable the monitoring of all warn metrics")
|
||||
err = a.setWarnMetricsStatus(model.WARN_METRIC_STATUS_ACK)
|
||||
err := a.setWarnMetricsStatus(model.WARN_METRIC_STATUS_ACK)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user