diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-03-02 00:46:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-01 16:46:02 +0000 |
commit | 4b8293aa094e725b372329a19da687a6d1550069 (patch) | |
tree | 83be14d110992096e39dcfb171bf70e58941eeb0 /models/issues/content_history.go | |
parent | 3b99066aa866e51e6a610716eaddfd1ea3645a67 (diff) | |
download | gitea-4b8293aa094e725b372329a19da687a6d1550069.tar.gz gitea-4b8293aa094e725b372329a19da687a6d1550069.zip |
Fix issue & comment history bugs (#29525)
* Follow #17746: `HasIssueContentHistory` should use expr builder to
make sure zero value (0) be respected.
* Add "doer" check to make sure `canSoftDeleteContentHistory` only be
called by sign-in users.
Diffstat (limited to 'models/issues/content_history.go')
-rw-r--r-- | models/issues/content_history.go | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/models/issues/content_history.go b/models/issues/content_history.go index 8b00adda99..31c80d2cea 100644 --- a/models/issues/content_history.go +++ b/models/issues/content_history.go @@ -172,13 +172,9 @@ func FetchIssueContentHistoryList(dbCtx context.Context, issueID, commentID int6 // HasIssueContentHistory check if a ContentHistory entry exists func HasIssueContentHistory(dbCtx context.Context, issueID, commentID int64) (bool, error) { - exists, err := db.GetEngine(dbCtx).Cols("id").Exist(&ContentHistory{ - IssueID: issueID, - CommentID: commentID, - }) + exists, err := db.GetEngine(dbCtx).Where(builder.Eq{"issue_id": issueID, "comment_id": commentID}).Exist(&ContentHistory{}) if err != nil { - log.Error("can not fetch issue content history. err=%v", err) - return false, err + return false, fmt.Errorf("can not check issue content history. err: %w", err) } return exists, err } |