1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-22 16:47:30 +00:00
forgejo/services
Earl Warren 5cc62caec7
[v1.22] [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)
(cherry picked from commit 3540ea2a43)

Conflicts:
	services/issue/issue.go
	https://codeberg.org/forgejo/forgejo/pulls/1415
(cherry picked from commit 56720ade00)

Conflicts:
	routers/api/v1/repo/issue_label.go
	https://codeberg.org/forgejo/forgejo/pulls/1462
(cherry picked from commit 47c78927d6)
(cherry picked from commit 2030f3b965)
(cherry picked from commit f02aeb7698)

Conflicts:
	routers/api/v1/repo/issue_attachment.go
	routers/api/v1/repo/issue_comment_attachment.go
	https://codeberg.org/forgejo/forgejo/pulls/1575
(cherry picked from commit d072525b35)
(cherry picked from commit 8424d0ab3d)
2023-10-23 14:16:25 +02:00
..
actions Always delete existing scheduled action tasks () 2023-10-18 10:34:39 +00:00
agit Penultimate round of db.DefaultContext refactor () 2023-10-11 04:24:07 +00:00
asymkey Penultimate round of db.DefaultContext refactor () 2023-10-11 04:24:07 +00:00
attachment [v1.22] [FEAT] allow setting the update date on issues and comments 2023-10-23 14:16:25 +02:00
auth [TESTS] oauth2: make it possible to use an alternate http.Client 2023-10-23 14:16:23 +02:00
automerge Improve queue and logger context () 2023-05-26 07:31:55 +00:00
context Another round of db.DefaultContext refactor () 2023-09-25 13:17:37 +00:00
convert [FEAT] add Forgero Git Service 2023-10-23 14:16:24 +02:00
cron Improve retrying index issues () 2023-10-15 18:56:57 +00:00
externalaccount Final round of db.DefaultContext refactor () 2023-10-14 08:37:24 +00:00
feed More db.DefaultContext refactor () 2023-09-29 12:12:54 +00:00
forgejo [v1.22] [UPGRADE] run sanity checks before the database is upgraded 2023-10-23 14:16:25 +02:00
forms Add support for forking single branch () 2023-09-29 09:48:39 +08:00
gitdiff Even more db.DefaultContext refactor () 2023-10-03 10:30:41 +00:00
indexer Improve retrying index issues () 2023-10-15 18:56:57 +00:00
issue [v1.22] [FEAT] allow setting the update date on issues and comments 2023-10-23 14:16:25 +02:00
lfs Bump github.com/golang-jwt/jwt to v5 () 2023-07-19 09:57:10 +00:00
mailer Penultimate round of db.DefaultContext refactor () 2023-10-11 04:24:07 +00:00
markup make writing main test easier () 2023-09-28 01:38:53 +00:00
migrations Final round of db.DefaultContext refactor () 2023-10-14 08:37:24 +00:00
mirror Even more db.DefaultContext refactor () 2023-10-03 10:30:41 +00:00
notify Update status and code index after changing the default branch () 2023-09-13 04:43:31 +00:00
org Delete repos of org when purge delete user () 2023-10-19 13:16:11 +00:00
packages Another round of db.DefaultContext refactor () 2023-09-25 13:17:37 +00:00
pull Fix poster is not loaded in get default merge message () 2023-10-17 15:07:23 +00:00
release Even more db.DefaultContext refactor () 2023-10-03 10:30:41 +00:00
repository Add doctor dbconsistency fix to delete repos with no owner () 2023-10-19 15:20:52 +02:00
secrets Refactor secrets modification logic () 2023-09-05 15:21:02 +00:00
task Fix incorrect ctx usage in defer function () 2023-10-22 14:12:27 +00:00
uinotification Penultimate round of db.DefaultContext refactor () 2023-10-11 04:24:07 +00:00
user Delete repos of org when purge delete user () 2023-10-19 13:16:11 +00:00
webhook Support allowed hosts for webhook to work with proxy () 2023-10-18 09:44:36 +00:00
wiki Even more db.DefaultContext refactor () 2023-10-03 10:30:41 +00:00