gitforge/models
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
..
actions [v16.0/forgejo] fix: ensure runners either belong to owner or repo when updated (#13266) 2026-07-01 04:55:17 +02:00
activities [v16.0/forgejo] feat: granular settings for watched repo units (#13385) 2026-07-09 20:56:52 +02:00
admin
asymkey chore: make use of go1.26 features (#12369) 2026-05-01 22:51:48 +02:00
auth feat: enable auth to git HTTP via authorized integrations (#12715) 2026-05-25 19:33:36 +02:00
avatars feat: serve downsized versions of avatars (#11242) 2026-05-16 12:04:05 +02:00
db chore: upgrade to https://code.forgejo.org/xorm/xorm v1.4.0 (#12639) 2026-05-20 20:20:08 +02:00
dbfs
fixtures [v16.0/forgejo] feat: granular settings for watched repo units (#13385) 2026-07-09 20:56:52 +02:00
forgefed chore(federation): re-enable nilnil lint (#11253) 2026-04-13 22:05:29 +02:00
forgejo/semver
forgejo_migrations [v16.0/forgejo] feat: granular settings for watched repo units (#13385) 2026-07-09 20:56:52 +02:00
forgejo_migrations_legacy chore: upgrade to https://code.forgejo.org/xorm/xorm v1.4.0 (#12639) 2026-05-20 20:20:08 +02:00
git 2026-06-10 security patches (#13001) 2026-06-10 06:05:01 +02:00
gitea_migrations [v16.0/forgejo] feat: granular settings for watched repo units (#13385) 2026-07-09 20:56:52 +02:00
issues [v16.0/forgejo] feat: granular settings for watched repo units (#13385) 2026-07-09 20:56:52 +02:00
moderation
organization feat: setting to add team members by invitations (#12845) 2026-06-15 01:46:25 +02:00
packages [v16.0/forgejo] fix: Update swift package registry to use the metadata schema from the official Swift docs (#13208) 2026-06-27 23:53:43 +02:00
perm
project feat(build): Support go "fmt" format strings as masked usage patterns (#12013) 2026-05-01 02:46:01 +02:00
pull
quota
repo [v16.0/forgejo] feat: granular settings for watched repo units (#13385) 2026-07-09 20:56:52 +02:00
secret fix: secret name-prefix regex (#12213) 2026-04-21 19:55:16 +02:00
shared/types
system feat(build): Support go "fmt" format strings as masked usage patterns (#12013) 2026-05-01 02:46:01 +02:00
unit
unittest [v16.0/forgejo] feat: granular settings for watched repo units (#13385) 2026-07-09 20:56:52 +02:00
user fix(ui): fall back to default theme from non-existent (#13110) 2026-06-17 19:18:09 +02:00
webhook
error.go
main_test.go
org.go [v16.0/forgejo] feat: granular settings for watched repo units (#13385) 2026-07-09 20:56:52 +02:00
org_team.go [v16.0/forgejo] feat: granular settings for watched repo units (#13385) 2026-07-09 20:56:52 +02:00
org_team_test.go
org_test.go
repo.go [v16.0/forgejo] feat: granular settings for watched repo units (#13385) 2026-07-09 20:56:52 +02:00
repo_test.go
repo_transfer.go
repo_transfer_test.go