mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-05 18:42:52 +01:00
08a2bed45d
This field adds the possibility to set the update date when modifying an issue through the API. A 'NoAutoDate' in-memory field is added in the Issue struct. If the update_at field is set, NoAutoDate is set to true and the Issue's UpdatedUnix field is filled. That information is passed down to the functions that actually updates the database, which have been modified to not auto update dates if requested. A guard is added to the 'EditIssue' API call, to checks that the udpate_at date is between the issue's creation date and the current date (to avoid 'malicious' changes). It also limits the new feature to project's owners and admins. (cherry picked from commitc524d33402
) Add a SetIssueUpdateDate() function in services/issue.go That function is used by some API calls to set the NoAutoDate and UpdatedUnix fields of an Issue if an updated_at date is provided. (cherry picked from commitf061caa655
) Add an updated_at field to the API calls related to Issue's Labels. The update date is applied to the issue's comment created to inform about the modification of the issue's labels. (cherry picked from commitea36cf80f5
) Add an updated_at field to the API call for issue's attachment creation The update date is applied to the issue's comment created to inform about the modification of the issue's content, and is set as the asset creation date. (cherry picked from commit96150971ca
) Checking Issue changes, with and without providing an updated_at date Those unit tests are added: - TestAPIEditIssueWithAutoDate - TestAPIEditIssueWithNoAutoDate - TestAPIAddIssueLabelsWithAutoDate - TestAPIAddIssueLabelsWithNoAutoDate - TestAPICreateIssueAttachmentWithAutoDate - TestAPICreateIssueAttachmentWithNoAutoDate (cherry picked from commit4926a5d7a2
) Add an updated_at field to the API call for issue's comment creation The update date is used as the comment creation date, and is applied to the issue as the update creation date. (cherry picked from commit76c8faecdc
) Add an updated_at field to the API call for issue's comment edition The update date is used as the comment update date, and is applied to the issue as an update date. (cherry picked from commitcf787ad7fd
) Add an updated_at field to the API call for comment's attachment creation The update date is applied to the comment, and is set as the asset creation date. (cherry picked from commit1e4ff424d3
) Checking Comment changes, with and without providing an updated_at date Those unit tests are added: - TestAPICreateCommentWithAutoDate - TestAPICreateCommentWithNoAutoDate - TestAPIEditCommentWithAutoDate - TestAPIEditCommentWithNoAutoDate - TestAPICreateCommentAttachmentWithAutoDate - TestAPICreateCommentAttachmentWithNoAutoDate (cherry picked from commitda932152f1
) Pettier code to set the update time of comments Now uses sess.AllCols().NoAutoToime().SetExpr("updated_unix", ...) XORM is smart enough to compose one single SQL UPDATE which all columns + updated_unix. (cherry picked from commit1f6a42808d
) Issue edition: Keep the max of the milestone and issue update dates. When editing an issue via the API, an updated_at date can be provided. If the EditIssue call changes the issue's milestone, the milestone's update date is to be changed accordingly, but only with a greater value. This ensures that a milestone's update date is the max of all issue's update dates. (cherry picked from commit8f22ea182e
) Rewrite the 'AutoDate' tests using subtests Also add a test to check the permissions to set a date, and a test to check update dates on milestones. The tests related to 'AutoDate' are: - TestAPIEditIssueAutoDate - TestAPIAddIssueLabelsAutoDate - TestAPIEditIssueMilestoneAutoDate - TestAPICreateIssueAttachmentAutoDate - TestAPICreateCommentAutoDate - TestAPIEditCommentWithDate - TestAPICreateCommentAttachmentAutoDate (cherry picked from commit961fd13c55
) (cherry picked from commitd52f4eea44
) (cherry picked from commit3540ea2a43
) Conflicts: services/issue/issue.go https://codeberg.org/forgejo/forgejo/pulls/1415 (cherry picked from commit56720ade00
) Conflicts: routers/api/v1/repo/issue_label.go https://codeberg.org/forgejo/forgejo/pulls/1462 (cherry picked from commit47c78927d6
) (cherry picked from commit2030f3b965
) (cherry picked from commitf02aeb7698
) (cherry picked from commit2e43e49961
) (cherry picked from commit3bfb6cc1c0
) (cherry picked from commit38918d5f5c
) (cherry picked from commit174f6ac345
)
86 lines
2.7 KiB
Go
86 lines
2.7 KiB
Go
// Copyright 2016 The Gogs Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package structs
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// Comment represents a comment on a commit or issue
|
|
type Comment struct {
|
|
ID int64 `json:"id"`
|
|
HTMLURL string `json:"html_url"`
|
|
PRURL string `json:"pull_request_url"`
|
|
IssueURL string `json:"issue_url"`
|
|
Poster *User `json:"user"`
|
|
OriginalAuthor string `json:"original_author"`
|
|
OriginalAuthorID int64 `json:"original_author_id"`
|
|
Body string `json:"body"`
|
|
Attachments []*Attachment `json:"assets"`
|
|
// swagger:strfmt date-time
|
|
Created time.Time `json:"created_at"`
|
|
// swagger:strfmt date-time
|
|
Updated time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// CreateIssueCommentOption options for creating a comment on an issue
|
|
type CreateIssueCommentOption struct {
|
|
// required:true
|
|
Body string `json:"body" binding:"Required"`
|
|
// swagger:strfmt date-time
|
|
Updated *time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// EditIssueCommentOption options for editing a comment
|
|
type EditIssueCommentOption struct {
|
|
// required: true
|
|
Body string `json:"body" binding:"Required"`
|
|
// swagger:strfmt date-time
|
|
Updated *time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// TimelineComment represents a timeline comment (comment of any type) on a commit or issue
|
|
type TimelineComment struct {
|
|
ID int64 `json:"id"`
|
|
Type string `json:"type"`
|
|
|
|
HTMLURL string `json:"html_url"`
|
|
PRURL string `json:"pull_request_url"`
|
|
IssueURL string `json:"issue_url"`
|
|
Poster *User `json:"user"`
|
|
Body string `json:"body"`
|
|
// swagger:strfmt date-time
|
|
Created time.Time `json:"created_at"`
|
|
// swagger:strfmt date-time
|
|
Updated time.Time `json:"updated_at"`
|
|
|
|
OldProjectID int64 `json:"old_project_id"`
|
|
ProjectID int64 `json:"project_id"`
|
|
OldMilestone *Milestone `json:"old_milestone"`
|
|
Milestone *Milestone `json:"milestone"`
|
|
TrackedTime *TrackedTime `json:"tracked_time"`
|
|
OldTitle string `json:"old_title"`
|
|
NewTitle string `json:"new_title"`
|
|
OldRef string `json:"old_ref"`
|
|
NewRef string `json:"new_ref"`
|
|
|
|
RefIssue *Issue `json:"ref_issue"`
|
|
RefComment *Comment `json:"ref_comment"`
|
|
RefAction string `json:"ref_action"`
|
|
// commit SHA where issue/PR was referenced
|
|
RefCommitSHA string `json:"ref_commit_sha"`
|
|
|
|
ReviewID int64 `json:"review_id"`
|
|
|
|
Label *Label `json:"label"`
|
|
|
|
Assignee *User `json:"assignee"`
|
|
AssigneeTeam *Team `json:"assignee_team"`
|
|
// whether the assignees were removed or added
|
|
RemovedAssignee bool `json:"removed_assignee"`
|
|
|
|
ResolveDoer *User `json:"resolve_doer"`
|
|
|
|
DependentIssue *Issue `json:"dependent_issue"`
|
|
}
|