forgejo/services
fluzz 3540ea2a43
[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 c524d33402)

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 f061caa655)

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 ea36cf80f5)

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 96150971ca)

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 4926a5d7a2)

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 76c8faecdc)

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 cf787ad7fd)

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 1e4ff424d3)

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 da932152f1)

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 1f6a42808d)

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 8f22ea182e)

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 961fd13c55)
(cherry picked from commit d52f4eea44)
2023-09-04 10:40:26 +02:00
..
actions chore(actions): support cron schedule task (#26655) 2023-08-24 03:06:51 +00:00
agit Add context parameter to some database functions (#26055) 2023-07-22 22:14:27 +08:00
asymkey Add context cache as a request level cache (#22294) 2023-02-15 21:37:34 +08:00
attachment [FEAT] allow setting the update date on issues and comments 2023-09-04 10:40:26 +02:00
auth [TESTS] oauth2: make it possible to use an alternate http.Client 2023-09-04 10:03:58 +02:00
automerge Improve queue and logger context (#24924) 2023-05-26 07:31:55 +00:00
context Replace interface{} with any (#25686) 2023-07-04 18:36:08 +00:00
convert [FEAT] add Forgero Git Service 2023-09-04 10:40:26 +02:00
cron chore(actions): support cron schedule task (#26655) 2023-08-24 03:06:51 +00:00
externalaccount Replace interface{} with any (#25686) 2023-07-04 18:36:08 +00:00
forgejo [UPGRADE] add sanity checks for [storage*] 2023-09-04 10:07:02 +02:00
forms Check blocklist for emails when adding them to account (#26812) 2023-08-30 10:46:49 -05:00
gitdiff Use Go 1.21 and update dependencies (#26878) 2023-09-03 10:34:57 +00:00
issue [FEAT] allow setting the update date on issues and comments 2023-09-04 10:40:26 +02:00
lfs Bump github.com/golang-jwt/jwt to v5 (#25975) 2023-07-19 09:57:10 +00:00
mailer Update team invitation email link (#26550) 2023-08-31 16:26:13 +00:00
markup Move web/api context related testing function into a separate package (#26859) 2023-09-01 11:26:07 +00:00
migrations Use Set[Type] instead of map[Type]bool/struct{}. (#26804) 2023-08-30 06:55:25 +00:00
mirror Move modules/mirror to services (#26737) 2023-08-27 10:24:45 +08:00
org Refactor rename user and rename organization (#24052) 2023-05-21 23:13:47 +08:00
packages Reduce some allocations in type conversion (#26772) 2023-08-29 00:43:16 +08:00
pull Reduce some allocations in type conversion (#26772) 2023-08-29 00:43:16 +08:00
release Less naked returns (#25713) 2023-07-07 05:31:56 +00:00
repository Move web/api context related testing function into a separate package (#26859) 2023-09-01 11:26:07 +00:00
task Add Retry button when creating a mirror-repo fails (#26228) 2023-08-04 10:21:32 +08:00
user add unit test for user renaming (#26261) 2023-08-03 09:38:51 +08:00
webhook Modify the content format of the Feishu webhook (#25106) 2023-08-24 09:00:11 +08:00
wiki Introduce ctx.PathParamRaw to avoid incorrect unescaping (#26392) 2023-08-09 14:57:45 +08:00