New report router and user reporting refactoring (#25713)
* Added materialized view migration * Renamed mat view * Added channel membership mat view and indexes * Added channel membership mat view and indexes * Added new index * WIP * Simplifying user reporting code * Created app and API layer for cahnnel reporting, reporting refactoring in general * New router * Remobved channel reporting meanwhile * Upodated autogenerated stuff * Lint fix * Fixed typo * api vet * i18n fix * Fixed API vetting and removed channel reporting constants * yaml * removed app pagination tests
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
32880efa25
Коммит
97a23d791e
32
server/channels/app/report.go
Обычный файл
32
server/channels/app/report.go
Обычный файл
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package app
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
)
|
||||
|
||||
func (a *App) GetUsersForReporting(filter *model.UserReportOptions) ([]*model.UserReport, *model.AppError) {
|
||||
if appErr := filter.IsValid(); appErr != nil {
|
||||
return nil, appErr
|
||||
}
|
||||
|
||||
return a.getUserReport(filter)
|
||||
}
|
||||
|
||||
func (a *App) getUserReport(filter *model.UserReportOptions) ([]*model.UserReport, *model.AppError) {
|
||||
userReportQuery, err := a.Srv().Store().User().GetUserReport(filter)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetUsersForReporting", "app.report.get_user_report.store_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
userReports := make([]*model.UserReport, len(userReportQuery))
|
||||
for i, user := range userReportQuery {
|
||||
userReports[i] = user.ToReport()
|
||||
}
|
||||
|
||||
return userReports, nil
|
||||
}
|
||||
Ссылка в новой задаче
Block a user