2019-05-11 10:21:34 +00:00
|
|
|
// Copyright 2016 The Gogs Authors. All rights reserved.
|
2022-11-27 18:20:29 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2019-05-11 10:21:34 +00:00
|
|
|
|
|
|
|
package structs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Comment represents a comment on a commit or issue
|
|
|
|
type Comment struct {
|
2022-12-09 06:35:56 +00:00
|
|
|
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"`
|
2019-05-11 10:21:34 +00:00
|
|
|
// 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"`
|
[FEAT] allow setting the update date on issues and comments
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 commit c524d33402c76bc4cccea2806f289e08a009baae)
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 commit f061caa6555e0c9e922ee1e73dd2e4337360e9fe)
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 commit ea36cf80f58f0ab20c565a8f5d063b90fd741f97)
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 commit 96150971ca31b97e97e84d5f5eb95a177cc44e2e)
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 commit 4926a5d7a28581003545256632213bf4136b193d)
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 commit 76c8faecdc6cba48ca4fe07d1a916d1f1a4b37b4)
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 commit cf787ad7fdb8e6273fdc35d7b5cc164b400207e9)
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 commit 1e4ff424d39db7a4256cd9abf9c58b8d3e1b5c14)
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 commit da932152f1deb3039a399516a51c8b6757059c91)
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 commit 1f6a42808dd739c0c2e49e6b7ae2967f120f43c2)
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 commit 8f22ea182e6b49e933dc6534040160dd739ff18a)
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 commit 961fd13c551b3e50040acb7c914a00ead92de63f)
2023-05-30 16:42:58 +00:00
|
|
|
// swagger:strfmt date-time
|
|
|
|
Updated *time.Time `json:"updated_at"`
|
2019-05-11 10:21:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// EditIssueCommentOption options for editing a comment
|
|
|
|
type EditIssueCommentOption struct {
|
|
|
|
// required: true
|
|
|
|
Body string `json:"body" binding:"Required"`
|
[FEAT] allow setting the update date on issues and comments
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 commit c524d33402c76bc4cccea2806f289e08a009baae)
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 commit f061caa6555e0c9e922ee1e73dd2e4337360e9fe)
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 commit ea36cf80f58f0ab20c565a8f5d063b90fd741f97)
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 commit 96150971ca31b97e97e84d5f5eb95a177cc44e2e)
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 commit 4926a5d7a28581003545256632213bf4136b193d)
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 commit 76c8faecdc6cba48ca4fe07d1a916d1f1a4b37b4)
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 commit cf787ad7fdb8e6273fdc35d7b5cc164b400207e9)
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 commit 1e4ff424d39db7a4256cd9abf9c58b8d3e1b5c14)
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 commit da932152f1deb3039a399516a51c8b6757059c91)
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 commit 1f6a42808dd739c0c2e49e6b7ae2967f120f43c2)
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 commit 8f22ea182e6b49e933dc6534040160dd739ff18a)
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 commit 961fd13c551b3e50040acb7c914a00ead92de63f)
2023-05-30 16:42:58 +00:00
|
|
|
// swagger:strfmt date-time
|
|
|
|
Updated *time.Time `json:"updated_at"`
|
2019-05-11 10:21:34 +00:00
|
|
|
}
|
2022-01-01 14:12:25 +00:00
|
|
|
|
|
|
|
// 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"`
|
|
|
|
}
|