forgejo/modules/structs
Earl Warren c7a389f2b2
[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)
(cherry picked from commit 5cc62caec7)
(cherry picked from commit d6300d5dcd)

[FEAT] allow setting the update date on issues and comments (squash) apply the 'update_at' value to the cross-ref comments (#1676)

[this is a follow-up to PR #764]

When a comment of issue A referencing issue B is added with a forced 'updated_at' date, that date has to be applied to the comment created in issue B.

-----

Comment:

While trying my 'RoundUp migration script', I found that this case was forgotten in PR #764 - my apologies...

I'll try to write a functional test, base on models/issues/issue_xref_test.go

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/1676
Co-authored-by: fluzz <fluzz@freedroid.org>
Co-committed-by: fluzz <fluzz@freedroid.org>
(cherry picked from commit ac4f727f63)
(cherry picked from commit 5110476ee9)
(cherry picked from commit 77ba6be1da)
(cherry picked from commit 9c8337b5c4)
(cherry picked from commit 1d689eb686)
(cherry picked from commit 511c519c87)
(cherry picked from commit 2f0b4a8f61)
(cherry picked from commit fdd4da111c)

[FEAT] allow setting the update date on issues and comments (squash) do not use token= query param

See https://codeberg.org/forgejo/forgejo/commit/33439b733a

(cherry picked from commit c5139a75b9)
(cherry picked from commit c7b572c35d)
(cherry picked from commit aec7503ff6)
(cherry picked from commit 87c65f2a49)
(cherry picked from commit bd47ee33c2)
(cherry picked from commit f3dbd90a74)
2024-02-05 14:44:33 +01:00
..
activity.go Add activity feeds API (#23494) 2023-04-04 21:35:31 +08:00
activitypub.go
admin_user.go chore(api): support ignore password if login source type is LDAP for creating user API (#28491) 2023-12-19 02:32:45 +00:00
attachment.go
commit_status.go Restore warning commit status (#27504) 2023-10-08 22:16:06 +00:00
commit_status_test.go refactor improve NoBetterThan (#26126) 2023-07-26 08:52:07 +00:00
cron.go
doc.go
fork.go
git_blob.go
git_hook.go
hook.go Add branch_filter to hooks API endpoints (#26599) 2023-08-21 11:43:52 +00:00
issue.go [FEAT] allow setting the update date on issues and comments 2024-02-05 14:44:33 +01:00
issue_comment.go [FEAT] allow setting the update date on issues and comments 2024-02-05 14:44:33 +01:00
issue_label.go [FEAT] allow setting the update date on issues and comments 2024-02-05 14:44:33 +01:00
issue_milestone.go
issue_reaction.go
issue_stopwatch.go
issue_test.go
issue_tracked_time.go
lfs_lock.go
mirror.go Fix push mirror, wrong timestamp format (#27153) 2023-09-23 12:15:05 +00:00
miscellaneous.go Add API for gitignore templates (#22783) 2023-04-27 11:51:20 +08:00
nodeinfo.go
notifications.go
org.go Allow Organisations to have a E-Mail (#25082) 2023-07-25 08:26:27 +00:00
org_member.go
org_team.go Doc update swagger doc for POST /orgs/{org}/teams (#26155) 2023-07-26 10:22:56 +00:00
package.go Fix package webhook (#27839) 2023-10-31 04:43:38 +00:00
pull.go Add the ability to pin Issues (#24406) 2023-05-25 15:17:19 +02:00
pull_review.go
release.go add Upload URL to release API (#26663) 2023-08-24 10:36:10 +00:00
repo.go Add support for sha256 repositories (#23894) 2024-01-19 17:05:02 +01:00
repo_branch.go Add branch protection setting for ignoring stale approvals (#28498) 2024-01-15 07:20:01 +00:00
repo_collaborator.go
repo_commit.go Add file status for API "Get a single commit from a repository" (#16205) (#25831) 2023-07-20 16:35:47 +08:00
repo_file.go Refactor "Content" for file uploading (#25851) 2023-07-18 18:14:47 +00:00
repo_key.go
repo_note.go
repo_refs.go
repo_tag.go
repo_topic.go
repo_tree.go
repo_watch.go Replace interface{} with any (#25686) 2023-07-04 18:36:08 +00:00
repo_wiki.go
secret.go refactor(API): refactor secret creation and update functionality (#26751) 2023-08-28 13:08:19 +08:00
settings.go
status.go
task.go Make repo migration cancelable and fix various bugs (#24605) 2023-05-11 08:25:46 +00:00
user.go Add API for changing Avatars (#25369) 2023-06-29 23:22:55 +00:00
user_app.go
user_email.go add admin API email endpoints (#22792) 2023-03-14 03:54:40 -04:00
user_gpgkey.go
user_key.go
visible_type.go