mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-19 07:30:50 +00:00
This implements milestones 1. and 4. from **Task F. Moderation features: Reporting** (part of [amendment of the workplan](https://codeberg.org/forgejo/sustainability/src/branch/main/2022-12-01-nlnet/2025-02-07-extended-workplan.md#task-f-moderation-features-reporting) for NLnet 2022-12-035): > 1. A reporting feature is implemented in the database. It ensures that content remains available for review, even if a user deletes it after a report was sent. > 4. Users can report the most relevant content types (at least: issue comments, repositories, users) ### See also: - forgejo/discussions#291 - forgejo/discussions#304 - forgejo/design#30 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6977 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Reviewed-by: Otto <otto@codeberg.org> Co-authored-by: floss4good <floss4good@disroot.org> Co-committed-by: floss4good <floss4good@disroot.org>
28 lines
974 B
Go
28 lines
974 B
Go
// Copyright 2025 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package forms
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"forgejo.org/models/moderation"
|
|
"forgejo.org/modules/web/middleware"
|
|
"forgejo.org/services/context"
|
|
|
|
"code.forgejo.org/go-chi/binding"
|
|
)
|
|
|
|
// ReportAbuseForm is used to interact with the UI of the form that submits new abuse reports.
|
|
type ReportAbuseForm struct {
|
|
ContentID int64
|
|
ContentType moderation.ReportedContentType
|
|
AbuseCategory moderation.AbuseCategoryType `binding:"Required" locale:"moderation.abuse_category"`
|
|
Remarks string `binding:"Required;MinSize(20);MaxSize(500)" preprocess:"TrimSpace" locale:"moderation.report_remarks"`
|
|
}
|
|
|
|
// Validate validates the fields of ReportAbuseForm.
|
|
func (f *ReportAbuseForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
|
|
ctx := context.GetValidateContext(req)
|
|
return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
|
|
}
|