Files
team/server/public/model/content_flagging.go
8ea7485b54 Data spillage report generation UI (#36340)
* Added base fr report generation

* WIP

* implemented UI flow

* implemented UI flow

* restructured the modal code into sub components

* Refactoring and cleanup

* lint fixes, added new tests

* i18n fix

* test fix

* Updated test

* CI

* Several improvements

* WIP

* Added tests

* Addressed some security enhancements

* Created zip writer entery later

* Improved a test to check for file content

* Improved error handling

* Made a geneeric function

* Updated classes

* accepting comment in report API

* Added more tests

* Integrated new API param

* Removed an unnecessary check

* Made a geneeric function

* Made a geneeric function

* Made the comment body not required and updated API docs

* Updated report generation API call in download report button

* Included decision in report and removed confirmation when keeping message

* Updated test

* Add explicit wait for removeWithoutReportButton visibility in test

Prevent race condition by waiting for the button to be visible after UI transitions to skip-confirm step before clicking it.

Co-authored-by: Maria A Nunez <[email protected]>

* PR Feedback

* explicitelly added return statement

* Included actor details in report

* Updated tests

---------

Co-authored-by: maria.nunez <[email protected]>

Co-authored-by: Mattermost Build <[email protected]>

Co-authored-by: Hanzo Dev <[email protected]>
2026-05-18 20:24:50 +05:30

75 lines
2.2 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package model
import (
"net/http"
"slices"
"unicode/utf8"
)
const (
ContentFlaggingGroupName = "content_flagging"
ContentFlaggingPostType = PostCustomTypePrefix + "spillage_report"
ContentFlaggingBotUsername = "content-review"
commentMaxRunes = 1000
AsContentReviewerParam = "as_content_reviewer"
)
const (
ContentFlaggingStatusPending = "Pending"
ContentFlaggingStatusAssigned = "Assigned"
ContentFlaggingStatusRemoved = "Removed"
ContentFlaggingStatusRetained = "Retained"
)
const (
ContentFlaggingActionKeep = "keep"
ContentFlaggingActionRemove = "remove"
)
type FlagContentRequest struct {
Reason string `json:"reason"`
Comment string `json:"comment,omitempty"`
}
func (f *FlagContentRequest) IsValid(commentRequired bool, validReasons []string) *AppError {
if f.Reason == "" {
return NewAppError("FlagContentRequest.IsValid", "api.data_spillage.error.reason_required", nil, "", http.StatusBadRequest)
}
if !slices.Contains(validReasons, f.Reason) {
return NewAppError("FlagContentRequest.IsValid", "api.data_spillage.error.reason_invalid", nil, "", http.StatusBadRequest)
}
if commentRequired && f.Comment == "" {
return NewAppError("FlagContentRequest.IsValid", "api.data_spillage.error.comment_required", nil, "", http.StatusBadRequest)
}
if utf8.RuneCountInString(f.Comment) > commentMaxRunes {
return NewAppError("FlagContentRequest.IsValid", "api.data_spillage.error.comment_too_long", map[string]any{"MaxLength": commentMaxRunes}, "", http.StatusBadRequest)
}
return nil
}
type FlagContentActionRequest struct {
Comment string `json:"comment,omitempty"`
Action string `json:"action,omitempty"`
}
func (f *FlagContentActionRequest) IsValid(commentRequired bool) *AppError {
if commentRequired && f.Comment == "" {
return NewAppError("FlagContentActionRequest.IsValid", "api.data_spillage.error.comment_required", nil, "", http.StatusBadRequest)
}
if utf8.RuneCountInString(f.Comment) > commentMaxRunes {
return NewAppError("FlagContentActionRequest.IsValid", "api.data_spillage.error.comment_too_long", map[string]any{"MaxLength": commentMaxRunes}, "", http.StatusBadRequest)
}
return nil
}