From 2d9cae515b6f6df86041d2c31b17469e2199b5ff Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Fri, 16 Aug 2024 23:33:24 -0400 Subject: [PATCH] Prepare Issues, Comments, and PR structs for future integration with spam prevention services --- models/issues/comment.go | 10 ++++++++++ models/issues/issue.go | 10 ++++++++++ models/issues/pull.go | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/models/issues/comment.go b/models/issues/comment.go index 48b8e335d4..74ed3bc10e 100644 --- a/models/issues/comment.go +++ b/models/issues/comment.go @@ -294,6 +294,16 @@ type Comment struct { ReviewID int64 `xorm:"index"` Invalidated bool + // Store IP and UserAgent that will be temporarily stored for + // life of the struct so that it could potentially be used + // for sending to akismet or other spam detection services. + UserIP string `xorm:"-"` + UserAgent string `xorm:"-"` + + // Spam services will return a risk level. Could be used in + // the future to have a threshold for preventing sending emails. + RiskLevel int `xorm:"-"` + // Reference an issue or pull from another comment, issue or PR // All information is about the origin of the reference RefRepoID int64 `xorm:"index"` // Repo where the referencing diff --git a/models/issues/issue.go b/models/issues/issue.go index 40462ed09d..5a20baacc3 100644 --- a/models/issues/issue.go +++ b/models/issues/issue.go @@ -141,6 +141,16 @@ type Issue struct { TotalTrackedTime int64 `xorm:"-"` Assignees []*user_model.User `xorm:"-"` + // Store IP and UserAgent that will be temporarily stored for + // life of the struct so that it could potentially be used + // for sending to akismet or other spam detection services. + UserIP string `xorm:"-"` + UserAgent string `xorm:"-"` + + // Spam services will return a risk level. Could be used in + // the future to have a threshold for preventing sending emails. + RiskLevel int `xorm:"-"` + // IsLocked limits commenting abilities to users on an issue // with write access IsLocked bool `xorm:"NOT NULL DEFAULT false"` diff --git a/models/issues/pull.go b/models/issues/pull.go index 5fe95d56cc..21c5aa6ace 100644 --- a/models/issues/pull.go +++ b/models/issues/pull.go @@ -178,6 +178,16 @@ type PullRequest struct { MergeBase string `xorm:"VARCHAR(64)"` AllowMaintainerEdit bool `xorm:"NOT NULL DEFAULT false"` + // Store IP and UserAgent that will be temporarily stored for + // life of the struct so that it could potentially be used + // for sending to akismet or other spam detection services. + UserIP string `xorm:"-"` + UserAgent string `xorm:"-"` + + // Spam services will return a risk level. Could be used in + // the future to have a threshold for preventing sending emails. + RiskLevel int `xorm:"-"` + HasMerged bool `xorm:"INDEX"` MergedCommitID string `xorm:"VARCHAR(64)"` MergerID int64 `xorm:"INDEX"`