mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-04-23 03:21:35 +02:00
some cleanups
This commit is contained in:
parent
a93b85709e
commit
af2c8f763b
4 changed files with 1 additions and 67 deletions
|
@ -106,11 +106,6 @@ func IsReported(ctx context.Context, contentType ReportedContentType, contentID
|
|||
return reported
|
||||
}
|
||||
|
||||
// IsReportedUserBy reports whether reportedUserID is already reported by doerID.
|
||||
func IsReportedUserBy(ctx context.Context, doerID int64, reportedUserID int64) bool {
|
||||
return alreadyReportedBy(ctx, doerID, ReportedContentTypeUser, reportedUserID)
|
||||
}
|
||||
|
||||
// alreadyReportedBy returns if doerID has already submitted a report for contentType and contentID.
|
||||
func alreadyReportedBy(ctx context.Context, doerID int64, contentType ReportedContentType, contentID int64) bool {
|
||||
reported, _ := db.GetEngine(ctx).Exist(&AbuseReport{ReporterID: doerID, ContentType: contentType, ContentID: contentID})
|
||||
|
@ -122,64 +117,6 @@ func ReportAbuse(ctx context.Context, report *AbuseReport) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
return reportAbuse(ctx, report)
|
||||
}
|
||||
|
||||
/*
|
||||
// ReportUser creates a new abuse report regarding the user with the provided reportedUserID.
|
||||
func ReportUser(ctx context.Context, reporterID int64, reportedUserID int64, remarks string) error {
|
||||
if reporterID == reportedUserID {
|
||||
return nil
|
||||
}
|
||||
|
||||
report := &AbuseReport{
|
||||
ReporterID: reporterID,
|
||||
ContentType: ReportedContentTypeUser,
|
||||
ContentID: reportedUserID,
|
||||
Remarks: remarks,
|
||||
}
|
||||
|
||||
return reportAbuse(ctx, report)
|
||||
}
|
||||
|
||||
// ReportRepository creates a new abuse report regarding the repository with the provided ID.
|
||||
func ReportRepository(ctx context.Context, reporterID int64, repositoryID int64, remarks string) error {
|
||||
report := &AbuseReport{
|
||||
ReporterID: reporterID,
|
||||
ContentType: ReportedContentTypeRepository,
|
||||
ContentID: repositoryID,
|
||||
Remarks: remarks,
|
||||
}
|
||||
|
||||
return reportAbuse(ctx, report)
|
||||
}
|
||||
|
||||
// ReportIssue creates a new abuse report regarding the issue with the provided ID.
|
||||
func ReportIssue(ctx context.Context, reporterID int64, issueID int64, remarks string) error {
|
||||
report := &AbuseReport{
|
||||
ReporterID: reporterID,
|
||||
ContentType: ReportedContentTypeIssue,
|
||||
ContentID: issueID,
|
||||
Remarks: remarks,
|
||||
}
|
||||
|
||||
return reportAbuse(ctx, report)
|
||||
}
|
||||
|
||||
// ReportComment creates a new abuse report regarding the comment with the provided ID.
|
||||
func ReportComment(ctx context.Context, reporterID int64, commentID int64, remarks string) error {
|
||||
report := &AbuseReport{
|
||||
ReporterID: reporterID,
|
||||
ContentType: ReportedContentTypeComment,
|
||||
ContentID: commentID,
|
||||
Remarks: remarks,
|
||||
}
|
||||
|
||||
return reportAbuse(ctx, report)
|
||||
}
|
||||
*/
|
||||
|
||||
func reportAbuse(ctx context.Context, report *AbuseReport) error {
|
||||
if alreadyReportedBy(ctx, report.ReporterID, report.ContentType, report.ContentID) {
|
||||
log.Warn("Seems that user %d wanted to report again the content with type %d and ID %d; this request will be ignored.", report.ReporterID, report.ContentType, report.ContentID)
|
||||
return nil
|
||||
|
|
|
@ -3962,7 +3962,6 @@ filepreview.truncated = Preview has been truncated
|
|||
|
||||
[moderation]
|
||||
report = Report
|
||||
;already_reported = Already reported
|
||||
report_abuse = Report abuse
|
||||
report_content = Report content
|
||||
report_abuse_form.header = Report abuse to administrator
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"net/url"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/moderation"
|
||||
"code.gitea.io/gitea/models/organization"
|
||||
packages_model "code.gitea.io/gitea/models/packages"
|
||||
access_model "code.gitea.io/gitea/models/perm/access"
|
||||
|
@ -40,7 +39,6 @@ func PrepareContextForProfileBigAvatar(ctx *context.Context) {
|
|||
prepareContextForCommonProfile(ctx)
|
||||
|
||||
ctx.Data["IsBlocked"] = ctx.Doer != nil && user_model.IsBlocked(ctx, ctx.Doer.ID, ctx.ContextUser.ID)
|
||||
ctx.Data["IsReported"] = ctx.Doer != nil && moderation.IsReportedUserBy(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
|
||||
if setting.Service.UserLocationMapURL != "" {
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
{{end}}
|
||||
</li>
|
||||
<li class="block" hx-target="#profile-avatar-card" hx-indicator="#profile-avatar-card">
|
||||
<a {{if $.IsReported}}disabled {{end}}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>
|
||||
{{end}}
|
||||
</ul>
|
||||
|
|
Loading…
Add table
Reference in a new issue