gitforge/models/fixtures
forgejo-backport-action 30b5ea66bc [v16.0/forgejo] feat: granular settings for watched repo units (#13385)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/10927

Continuation of #10598
Closes #7254

Implement repo granular watch selection

I adopted a lot of the frontend from #10598 while redoing the entire back-end. I propose this new model:
- Remove the WatchMode enum.
- Add the WatchSelection struct, which represents the granular selection. Notice that there is no `watching` bool. I tried very hard to keep the structure as simple and redundancy-free as possible. Therefore, people not watching a repo at all either don't have a watch record or one with an entirely unselected WatchSelection struct.
- Add the WatchSource enum. It replaces the WatchMode enum and has a single purpose: determine whether a watch was explicitly or automatically initiated.

Notice that replacing this
```go
		And("`watch`.mode<>?", WatchModeDont).
```
with this is correct:
```go
		And(
			builder.Or(
				builder.Eq{"`watch`.watch_selection_issues": true},
				builder.Eq{"`watch`.watch_selection_pull_requests": true},
				builder.Eq{"`watch`.watch_selection_releases": true},
			),
		).
```
That's because there are four modes: dont, none, auto and normal. When `<>` with dont, we look for auto and normal, because there are no records with none. Therefore, the old code looks for records that indicate watching. The code I replaced this with does so, too, just more granular.

Also notice that I've prepared a future `user preset` in a few places. See below for a little more info on that.

## Next PR
I plan to continue working on this. I want to implement a `user preset` option. The user sets that `user preset` in her settings and may use them in any repo.
<details>
- rename account settings to account and notifications
- user preset (always use this preset for newly accessible repos (according to AutoWatchOnChanges and AutoWatchNewRepos))
</details>

## Further PRs
- make api able to granular watch
- move (email) notifications to new notifications tab

Co-authored-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-authored-by: pat-s <patrick.schratz@gmail.com>
Reviewed-on: #10927
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
(cherry picked from commit 8770ffc848)
2026-07-09 20:56:52 +02:00
..
ModerationFeatures
PrivateIssueProjects fix(models): deduplicate project sorting values and add unique constraints (#11334) 2026-02-27 16:25:20 +01:00
TestActivateUserEmail
TestAddTeamReviewRequest
TestGetUnmergedPullRequestsByHeadInfoMax
TestGetUsedForUser
TestPackagesGetOrInsertBlob
TestParseCommitWithSSHSignature
TestPrivateRepoProjects fix(models): deduplicate project sorting values and add unique constraints (#11334) 2026-02-27 16:25:20 +01:00
TestTwoFactorWithPasswordChange
access.yml
access_token.yml
action.yml fix(activitypub): only return public activities on request (#12382) 2026-05-09 05:02:57 +02:00
action_artifact.yml
action_run.yml feat: add more filters to actions run and tasks api (#11584) 2026-03-10 01:20:00 +01:00
action_run_job.yml fix: do not hide previous attempts without task for latest attempt (#12779) 2026-05-28 15:16:48 +02:00
action_runner.yml
action_runner_token.yml feat: add foreign keys to the action_runner_token table (#10756) 2026-01-12 21:59:40 +01:00
action_task.yml feat(ui): show cancel button until all jobs are finished (#9261) 2025-12-21 17:09:22 +01:00
action_task_output.yml
action_user.yml
attachment.yml
branch.yml fix: Allow SHA-256 in PR commit URLs (#10309) 2025-12-16 00:45:00 +01:00
collaboration.yml
comment.yml refactor: migrate from lib/pq to jackc/pgx (#10219) 2025-11-30 17:47:45 +01:00
commit_status.yml feat: mark skipped checks as skipped (#12606) 2026-05-17 18:00:49 +02:00
commit_status_index.yml
email_address.yml
follow.yml
forgejo_blocked_user.yml
gpg_key.yml
hook_task.yml
issue.yml fix: Allow SHA-256 in PR commit URLs (#10309) 2025-12-16 00:45:00 +01:00
issue_assignees.yml
issue_index.yml fix: Allow SHA-256 in PR commit URLs (#10309) 2025-12-16 00:45:00 +01:00
issue_label.yml
issue_user.yml
issue_watch.yml
label.yml
language_stat.yml fix: load repo language for converting to api struct (#12737) 2026-05-28 17:00:40 +02:00
lfs_meta_object.yml
milestone.yml
mirror.yml
notice.yml
notification.yml
oauth2_application.yml
oauth2_authorization_code.yml
oauth2_grant.yml
org_user.yml
project.yml enh(issue-search): support filtering by project in user/org listing (#12596) 2026-05-17 12:00:25 +02:00
project_board.yml enh(issue-search): support filtering by project in user/org listing (#12596) 2026-05-17 12:00:25 +02:00
project_issue.yml enh(issue-search): support filtering by project in user/org listing (#12596) 2026-05-17 12:00:25 +02:00
protected_tag.yml
public_key.yml Exclude SSH certificate principals from output when viewing user's SSH keys (#12079) 2026-04-17 17:17:29 +02:00
pull_request.yml fix: Allow SHA-256 in PR commit URLs (#10309) 2025-12-16 00:45:00 +01:00
reaction.yml
release.yml
renamed_branch.yml
repo_redirect.yml
repo_topic.yml
repo_transfer.yml
repo_unit.yml fix: Allow SHA-256 in PR commit URLs (#10309) 2025-12-16 00:45:00 +01:00
repository.yml [v16.0/forgejo] feat: granular settings for watched repo units (#13385) 2026-07-09 20:56:52 +02:00
review.yml
star.yml
stopwatch.yml
system_setting.yml
team.yml refactor: migrate from lib/pq to jackc/pgx (#10219) 2025-11-30 17:47:45 +01:00
team_repo.yml
team_unit.yml
team_user.yml
topic.yml
tracked_time.yml
two_factor.yml
user.yml fix(ui): fall back to default theme from non-existent (#13110) 2026-06-17 19:18:09 +02:00
user_open_id.yml
user_redirect.yml
watch.yml [v16.0/forgejo] feat: granular settings for watched repo units (#13385) 2026-07-09 20:56:52 +02:00
webauthn_credential.yml
webhook.yml