gitforge/models/issues
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
..
TestGetParticipantIDsByIssue fix: don't display pending reviews as participants (#10528) 2026-01-06 10:47:21 +01:00
TestGetUIDsAndStopwatch
action_aggregator.go
action_aggregator_test.go
assignees.go
assignees_test.go
comment.go fix: multiline comment invalidation (#12950) 2026-06-09 03:07:56 +02:00
comment_code.go feat(api,ui): add multiline comment on pullrequest (#12582) 2026-06-03 16:06:29 +02:00
comment_list.go refactor: reduce code duplication when accessing DefaultMaxInSize (#11999) 2026-04-05 22:03:45 +02:00
comment_list_test.go perf: bulk load resolvers & reactions on pull request comments (#11988) 2026-04-05 14:37:09 +02:00
comment_test.go feat(api,ui): add multiline comment on pullrequest (#12582) 2026-06-03 16:06:29 +02:00
content_history.go chore: handle error types consistently (#9873) 2026-03-06 00:48:06 +01:00
content_history_test.go
dependency.go refactor: migrate from lib/pq to jackc/pgx (#10219) 2025-11-30 17:47:45 +01:00
dependency_test.go
issue.go fix: return API URL in the url field for pull requests using the API (#12643) 2026-05-25 04:01:17 +02:00
issue_index.go
issue_index_test.go
issue_label.go
issue_label_test.go
issue_list.go refactor: reduce code duplication when accessing DefaultMaxInSize (#11999) 2026-04-05 22:03:45 +02:00
issue_list_test.go
issue_lock.go
issue_project.go
issue_project_test.go
issue_search.go [v16.0/forgejo] feat: granular settings for watched repo units (#13385) 2026-07-09 20:56:52 +02:00
issue_stats.go chore: upgrade to https://code.forgejo.org/xorm/xorm v1.4.0 (#12639) 2026-05-20 20:20:08 +02:00
issue_stats_test.go
issue_test.go [v16.0/forgejo] feat: granular settings for watched repo units (#13385) 2026-07-09 20:56:52 +02:00
issue_update.go chore: add modernizer linter (#11936) 2026-04-02 03:29:37 +02:00
issue_user.go
issue_user_test.go refactor: migrate from lib/pq to jackc/pgx (#10219) 2025-11-30 17:47:45 +01:00
issue_watch.go [v16.0/forgejo] feat: granular settings for watched repo units (#13385) 2026-07-09 20:56:52 +02:00
issue_watch_test.go
issue_xref.go
issue_xref_test.go
label.go feat: improve label filtering exclusion (#10702) 2026-02-08 00:31:31 +01:00
label_internal_test.go
label_test.go feat: improve label filtering exclusion (#10702) 2026-02-08 00:31:31 +01:00
main_test.go chore: move all test blank imports in a single package (#10662) 2026-01-02 05:32:32 +01:00
milestone.go refactor: replace Value() from Option[T] with Get() & ValueOrZeroValue() (#11218) 2026-02-10 16:41:21 +01:00
milestone_internal_test.go
milestone_list.go refactor: replace Value() from Option[T] with Get() & ValueOrZeroValue() (#11218) 2026-02-10 16:41:21 +01:00
milestone_test.go refactor: migrate from lib/pq to jackc/pgx (#10219) 2025-11-30 17:47:45 +01:00
moderation.go feat: render a link to poster profile next to the ID within shadow copy details (#10194) 2025-12-09 15:19:10 +01:00
moderation_test.go feat: render a link to poster profile next to the ID within shadow copy details (#10194) 2025-12-09 15:19:10 +01:00
pull.go
pull_list.go chore: upgrade to https://code.forgejo.org/xorm/xorm v1.4.0 (#12639) 2026-05-20 20:20:08 +02:00
pull_test.go
reaction.go refactor: reduce code duplication when accessing DefaultMaxInSize (#11999) 2026-04-05 22:03:45 +02:00
reaction_test.go
review.go fix: Prevent unremovable review requests after submitting pending reviews (#12302) 2026-05-08 05:52:59 +02:00
review_list.go chore: add modernizer linter (#11936) 2026-04-02 03:29:37 +02:00
review_test.go fix: Prevent unremovable review requests after submitting pending reviews (#12302) 2026-05-08 05:52:59 +02:00
stopwatch.go
stopwatch_test.go
tracked_time.go chore: upgrade to https://code.forgejo.org/xorm/xorm v1.4.0 (#12639) 2026-05-20 20:20:08 +02:00
tracked_time_test.go