forgejo/services
fluzz d52f4eea44
[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)
2023-08-29 08:51:45 +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-08-29 08:51:45 +02:00
auth [TESTS] oauth2: make it possible to use an alternate http.Client 2023-08-29 08:47:10 +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-08-29 08:47:11 +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-08-29 08:47:11 +02:00
forms Allow to archive labels (#26478) 2023-08-14 11:56:14 +02:00
gitdiff Fix stderr usages (#26477) 2023-08-13 20:49:30 +08:00
issue [FEAT] allow setting the update date on issues and comments 2023-08-29 08:51:45 +02:00
lfs Bump github.com/golang-jwt/jwt to v5 (#25975) 2023-07-19 09:57:10 +00:00
mailer Replace interface{} with any (#25686) 2023-07-04 18:36:08 +00:00
markup Make web context initialize correctly for different cases (#26726) 2023-08-25 19:07:42 +08:00
migrations Add context parameter to some database functions (#26055) 2023-07-22 22:14:27 +08: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 Add link to job details and tooltip to commit status in repo list in dashboard (#26326) 2023-08-21 15:26:10 +08: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