mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-04-25 05:44:09 +00:00
Introduce new [moderation] ENABLED config (default false).
When defined within app.ini and the value is true, it will be possible to report abusive content.
This commit is contained in:
parent
24c8d105f1
commit
3afae67e11
14 changed files with 42 additions and 5 deletions
15
modules/setting/moderation.go
Normal file
15
modules/setting/moderation.go
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright 2025 The Forgejo Authors. All rights reserved.
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
package setting
|
||||||
|
|
||||||
|
// Moderation settings
|
||||||
|
var Moderation = struct {
|
||||||
|
Enabled bool `ini:"ENABLED"`
|
||||||
|
}{
|
||||||
|
Enabled: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadModerationFrom(rootCfg ConfigProvider) {
|
||||||
|
mustMapSetting(rootCfg, "moderation", &Moderation)
|
||||||
|
}
|
|
@ -227,6 +227,7 @@ func LoadSettings() {
|
||||||
loadProjectFrom(CfgProvider)
|
loadProjectFrom(CfgProvider)
|
||||||
loadMimeTypeMapFrom(CfgProvider)
|
loadMimeTypeMapFrom(CfgProvider)
|
||||||
loadF3From(CfgProvider)
|
loadF3From(CfgProvider)
|
||||||
|
loadModerationFrom(CfgProvider)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadSettingsForInstall initializes the settings for install
|
// LoadSettingsForInstall initializes the settings for install
|
||||||
|
|
|
@ -3484,6 +3484,8 @@ config.access_log_mode = Access log mode
|
||||||
config.access_log_template = Access log template
|
config.access_log_template = Access log template
|
||||||
config.xorm_log_sql = Log SQL
|
config.xorm_log_sql = Log SQL
|
||||||
|
|
||||||
|
config.moderation_config = Moderation configuration
|
||||||
|
|
||||||
config.set_setting_failed = Set setting %s failed
|
config.set_setting_failed = Set setting %s failed
|
||||||
|
|
||||||
monitor.stats = Stats
|
monitor.stats = Stats
|
||||||
|
|
|
@ -145,6 +145,7 @@ func Config(ctx *context.Context) {
|
||||||
ctx.Data["Service"] = setting.Service
|
ctx.Data["Service"] = setting.Service
|
||||||
ctx.Data["DbCfg"] = setting.Database
|
ctx.Data["DbCfg"] = setting.Database
|
||||||
ctx.Data["Webhook"] = setting.Webhook
|
ctx.Data["Webhook"] = setting.Webhook
|
||||||
|
ctx.Data["Moderation"] = setting.Moderation
|
||||||
|
|
||||||
ctx.Data["MailerEnabled"] = false
|
ctx.Data["MailerEnabled"] = false
|
||||||
if setting.MailService != nil {
|
if setting.MailService != nil {
|
||||||
|
|
|
@ -1475,6 +1475,7 @@ func ViewIssue(ctx *context.Context) {
|
||||||
ctx.Data["IssueType"] = "all"
|
ctx.Data["IssueType"] = "all"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.Data["IsModerationEnabled"] = setting.Moderation.Enabled
|
||||||
ctx.Data["IsProjectsEnabled"] = ctx.Repo.CanRead(unit.TypeProjects)
|
ctx.Data["IsProjectsEnabled"] = ctx.Repo.CanRead(unit.TypeProjects)
|
||||||
ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled
|
ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled
|
||||||
upload.AddUploadContext(ctx, "comment")
|
upload.AddUploadContext(ctx, "comment")
|
||||||
|
|
|
@ -38,6 +38,7 @@ func prepareContextForCommonProfile(ctx *context.Context) {
|
||||||
func PrepareContextForProfileBigAvatar(ctx *context.Context) {
|
func PrepareContextForProfileBigAvatar(ctx *context.Context) {
|
||||||
prepareContextForCommonProfile(ctx)
|
prepareContextForCommonProfile(ctx)
|
||||||
|
|
||||||
|
ctx.Data["IsModerationEnabled"] = setting.Moderation.Enabled
|
||||||
ctx.Data["IsBlocked"] = ctx.Doer != nil && user_model.IsBlocked(ctx, ctx.Doer.ID, ctx.ContextUser.ID)
|
ctx.Data["IsBlocked"] = ctx.Doer != nil && user_model.IsBlocked(ctx, ctx.Doer.ID, ctx.ContextUser.ID)
|
||||||
ctx.Data["IsFollowing"] = ctx.Doer != nil && user_model.IsFollowing(ctx, ctx.Doer.ID, ctx.ContextUser.ID)
|
ctx.Data["IsFollowing"] = ctx.Doer != nil && user_model.IsFollowing(ctx, ctx.Doer.ID, ctx.ContextUser.ID)
|
||||||
ctx.Data["ShowUserEmail"] = setting.UI.ShowUserEmail && ctx.ContextUser.Email != "" && ctx.IsSigned && !ctx.ContextUser.KeepEmailPrivate
|
ctx.Data["ShowUserEmail"] = setting.UI.ShowUserEmail && ctx.ContextUser.Email != "" && ctx.IsSigned && !ctx.ContextUser.KeepEmailPrivate
|
||||||
|
|
|
@ -481,8 +481,10 @@ func registerRoutes(m *web.Route) {
|
||||||
m.Get("/search", repo.SearchIssues)
|
m.Get("/search", repo.SearchIssues)
|
||||||
}, reqSignIn)
|
}, reqSignIn)
|
||||||
|
|
||||||
m.Get("/-/abuse_reports/new", reqSignIn, moderation.NewReport)
|
if setting.Moderation.Enabled {
|
||||||
m.Post("/-/abuse_reports/new", reqSignIn, web.Bind(forms.ReportAbuseForm{}), moderation.CreatePost)
|
m.Get("/-/abuse_reports/new", reqSignIn, moderation.NewReport)
|
||||||
|
m.Post("/-/abuse_reports/new", reqSignIn, web.Bind(forms.ReportAbuseForm{}), moderation.CreatePost)
|
||||||
|
}
|
||||||
|
|
||||||
m.Get("/pulls", reqSignIn, user.Pulls)
|
m.Get("/pulls", reqSignIn, user.Pulls)
|
||||||
m.Get("/milestones", reqSignIn, reqMilestonesDashboardPageEnabled, user.Milestones)
|
m.Get("/milestones", reqSignIn, reqMilestonesDashboardPageEnabled, user.Milestones)
|
||||||
|
|
|
@ -165,6 +165,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
|
||||||
ctx.Data["IsOrganizationMember"] = ctx.Org.IsMember
|
ctx.Data["IsOrganizationMember"] = ctx.Org.IsMember
|
||||||
ctx.Data["IsPackageEnabled"] = setting.Packages.Enabled
|
ctx.Data["IsPackageEnabled"] = setting.Packages.Enabled
|
||||||
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
|
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
|
||||||
|
ctx.Data["IsModerationEnabled"] = setting.Moderation.Enabled
|
||||||
ctx.Data["IsPublicMember"] = func(uid int64) bool {
|
ctx.Data["IsPublicMember"] = func(uid int64) bool {
|
||||||
is, _ := organization.IsPublicMembership(ctx, ctx.Org.Organization.ID, uid)
|
is, _ := organization.IsPublicMembership(ctx, ctx.Org.Organization.ID, uid)
|
||||||
return is
|
return is
|
||||||
|
|
|
@ -591,6 +591,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
|
||||||
ctx.Data["CanWriteIssues"] = ctx.Repo.CanWrite(unit_model.TypeIssues)
|
ctx.Data["CanWriteIssues"] = ctx.Repo.CanWrite(unit_model.TypeIssues)
|
||||||
ctx.Data["CanWritePulls"] = ctx.Repo.CanWrite(unit_model.TypePullRequests)
|
ctx.Data["CanWritePulls"] = ctx.Repo.CanWrite(unit_model.TypePullRequests)
|
||||||
ctx.Data["CanWriteActions"] = ctx.Repo.CanWrite(unit_model.TypeActions)
|
ctx.Data["CanWriteActions"] = ctx.Repo.CanWrite(unit_model.TypeActions)
|
||||||
|
ctx.Data["IsModerationEnabled"] = setting.Moderation.Enabled
|
||||||
|
|
||||||
canSignedUserFork, err := repo_module.CanUserForkRepo(ctx, ctx.Doer, ctx.Repo.Repository)
|
canSignedUserFork, err := repo_module.CanUserForkRepo(ctx, ctx.Doer, ctx.Repo.Repository)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -247,6 +247,16 @@
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<h4 class="ui top attached header">
|
||||||
|
{{ctx.Locale.Tr "admin.config.moderation_config"}}
|
||||||
|
</h4>
|
||||||
|
<div class="ui attached table segment">
|
||||||
|
<dl class="admin-dl-horizontal">
|
||||||
|
<dt>{{ctx.Locale.Tr "enabled"}}</dt>
|
||||||
|
<dd>{{if .Moderation.Enabled}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h4 class="ui top attached header">
|
<h4 class="ui top attached header">
|
||||||
{{ctx.Locale.Tr "admin.config.cache_config"}}
|
{{ctx.Locale.Tr "admin.config.cache_config"}}
|
||||||
</h4>
|
</h4>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
{{if .IsOrganizationMember}}
|
{{if .IsOrganizationMember}}
|
||||||
<a class="ui basic button tw-mr-0" href="{{.OrgLink}}/dashboard">{{ctx.Locale.Tr "org.open_dashboard"}}</a>
|
<a class="ui basic button tw-mr-0" href="{{.OrgLink}}/dashboard">{{ctx.Locale.Tr "org.open_dashboard"}}</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if and .IsSigned (not .IsOrganizationOwner)}}
|
{{if and .IsModerationEnabled .IsSigned (not .IsOrganizationOwner)}}
|
||||||
<button class="ui dropdown icon button" data-tooltip-content="{{ctx.Locale.Tr "repo.more_operations"}}" aria-label="{{ctx.Locale.Tr "toggle_menu"}}">
|
<button class="ui dropdown icon button" data-tooltip-content="{{ctx.Locale.Tr "repo.more_operations"}}" aria-label="{{ctx.Locale.Tr "toggle_menu"}}">
|
||||||
{{svg "octicon-kebab-horizontal" 14}}
|
{{svg "octicon-kebab-horizontal" 14}}
|
||||||
<div class="menu top left">
|
<div class="menu top left">
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
{{if not $.DisableForks}}
|
{{if not $.DisableForks}}
|
||||||
{{template "repo/header_fork" $}}
|
{{template "repo/header_fork" $}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if and $.IsSigned (not $.IsRepositoryAdmin)}}
|
{{if and $.IsModerationEnabled $.IsSigned (not $.IsRepositoryAdmin)}}
|
||||||
<button class="ui small compact jump dropdown icon button" data-tooltip-content="{{ctx.Locale.Tr "repo.more_operations"}}" aria-label="{{ctx.Locale.Tr "toggle_menu"}}">
|
<button class="ui small compact jump dropdown icon button" data-tooltip-content="{{ctx.Locale.Tr "repo.more_operations"}}" aria-label="{{ctx.Locale.Tr "toggle_menu"}}">
|
||||||
{{svg "octicon-kebab-horizontal"}}
|
{{svg "octicon-kebab-horizontal"}}
|
||||||
<div class="menu top left">
|
<div class="menu top left">
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if and .ctxData.IsSigned (not .IsCommentPoster)}}
|
{{if and .ctxData.IsModerationEnabled .ctxData.IsSigned (not .IsCommentPoster)}}
|
||||||
{{$contentType := "comment"}}
|
{{$contentType := "comment"}}
|
||||||
{{if eq .item .ctxData.Issue}}
|
{{if eq .item .ctxData.Issue}}
|
||||||
{{if .ctxData.Issue.IsPull}} {{$contentType = "pull"}} {{else}} {{$contentType = "issue"}} {{end}}
|
{{if .ctxData.Issue.IsPull}} {{$contentType = "pull"}} {{else}} {{$contentType = "issue"}} {{end}}
|
||||||
|
|
|
@ -123,10 +123,12 @@
|
||||||
</button>
|
</button>
|
||||||
{{end}}
|
{{end}}
|
||||||
</li>
|
</li>
|
||||||
|
{{if .IsModerationEnabled}}
|
||||||
<li class="block" hx-target="#profile-avatar-card" hx-indicator="#profile-avatar-card">
|
<li class="block" hx-target="#profile-avatar-card" hx-indicator="#profile-avatar-card">
|
||||||
<a class="ui basic orange button" href="/-/abuse_reports/new?type=user&id={{.ContextUser.ID}}">{{ctx.Locale.Tr "moderation.report_abuse"}}</a>
|
<a class="ui basic orange button" href="/-/abuse_reports/new?type=user&id={{.ContextUser.ID}}">{{ctx.Locale.Tr "moderation.report_abuse"}}</a>
|
||||||
</li>
|
</li>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{end}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue