mattermost/server/public/model/content_flagging_report.go
Harshil Sharma f0360a838a
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 <maria.nunez@mattermost.com>

* PR Feedback

* explicitelly added return statement

* Included actor details in report

* Updated tests

---------

Co-authored-by: maria.nunez <maria.nunez@mattermost.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2026-05-18 20:24:50 +05:30

88 lines
2.8 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package model
const FlaggedPostReportVersion = "1.0"
type FlaggedPostReportContext struct {
Post *Post
Channel *Channel
Team *Team
Author *User
EditHistory []*Post
}
// FlaggedPostReportPost is the on-disk shape for post.yaml. It
// embeds *Post to reuse common fields; the wire format is fixed by the
// MarshalYAML method below so the report layout does not depend on Post's
// own field tags.
type FlaggedPostReportPost struct {
*Post
AuthorName string
AuthorEmail string
ChannelDisplayName string
TeamID string
TeamDisplayName string
ReplyCountPtr *int64
EditHistoryOrder []string
}
func (f FlaggedPostReportPost) MarshalYAML() (any, error) {
out := map[string]any{
"author_name": f.AuthorName,
"author_email": f.AuthorEmail,
"channel_display_name": f.ChannelDisplayName,
"team_id": f.TeamID,
"team_display_name": f.TeamDisplayName,
}
if f.Post != nil {
out["id"] = f.Post.Id
out["author_id"] = f.Post.UserId
out["message"] = f.Post.Message
out["channel_id"] = f.Post.ChannelId
out["create_at"] = f.Post.CreateAt
out["update_at"] = f.Post.UpdateAt
out["is_pinned"] = f.Post.IsPinned
out["root_id"] = f.Post.RootId
if props := f.Post.GetProps(); len(props) > 0 {
out["props"] = props
}
if f.Post.Metadata != nil {
out["metadata"] = f.Post.Metadata
}
}
if f.ReplyCountPtr != nil {
out["reply_count"] = *f.ReplyCountPtr
}
if len(f.EditHistoryOrder) > 0 {
out["edit_history_order"] = f.EditHistoryOrder
}
return out, nil
}
// FlaggedPostReportContentReview is the on-disk shape for content_review.yaml.
type FlaggedPostReportContentReview struct {
ReporterUserID string `yaml:"reporter_user_id"`
ReporterUsername string `yaml:"reporter_username"`
ReporterReason string `yaml:"reporter_reason"`
ReporterComment string `yaml:"reporter_comment"`
ReportTimestamp int64 `yaml:"report_timestamp"`
Hidden bool `yaml:"hidden"`
ReviewerUserID string `yaml:"reviewer_user_id,omitempty"`
ReviewerUsername string `yaml:"reviewer_username,omitempty"`
ReviewerComment string `yaml:"reviewer_comment,omitempty"`
ActionTime int64 `yaml:"action_time,omitempty"`
ActorDecision string `yaml:"actor_decision,omitempty"`
ActorUserId string `yaml:"actor_user_id,omitempty"`
ActorUsername string `yaml:"actor_username,omitempty"`
}
// FlaggedPostReportMetadata is the on-disk shape for report_metadata.yaml.
type FlaggedPostReportMetadata struct {
GeneratedByUserID string `yaml:"generated_by_user_id"`
GeneratedByUsername string `yaml:"generated_by_username"`
Timestamp int64 `yaml:"timestamp"`
ReportVersion string `yaml:"report_version"`
}