Skip to content

fix(api): include effective subscribers in issue subscriptions list - #38655

Open
majorissuerep wants to merge 3 commits into
go-gitea:mainfrom
majorissuerep:fix/issue-26750-issue-subscription-api
Open

fix(api): include effective subscribers in issue subscriptions list#38655
majorissuerep wants to merge 3 commits into
go-gitea:mainfrom
majorissuerep:fix/issue-26750-issue-subscription-api

Conversation

@majorissuerep

Copy link
Copy Markdown
Contributor

Summary

GET /repos/{owner}/{repo}/issues/{index}/subscriptions only returned users with an explicit issue_watch row (is_watching=true).

That disagrees with how subscription actually works elsewhere:

  • Web UI shows Unsubscribe for participants (issue author / commenters) even without an explicit watch row
  • CheckIssueWatch (used by /subscriptions/check) treats participants and repo watchers as subscribed
  • Notification delivery includes the same sets (and honors explicit unsubscribes)

So the list API missed effective subscribers until someone toggled unsubscribe/subscribe to force an issue_watch row.

Fix

Add GetIssueSubscribers / CountIssueSubscribers that return the effective set:

  • explicit issue watchers (issue_watch.is_watching=true)
  • participants (comment types comment/code/review) and issue author
  • repository watchers (WatchModeNormal / WatchModeAuto)
  • minus explicit unsubscribers (issue_watch.is_watching=false)
  • only active, non-prohibited users

Wire the API list endpoint to those helpers. Keep GetIssueWatchers for callers that need explicit rows only.

Fixes #26750

Test plan

  • gofmt on touched files
  • go vet ./models/issues/ ./routers/api/v1/repo/
  • go test ./models/issues/ -run 'TestGetIssueWatch|TestGetIssueSubscribers|TestCreateOrUpdateIssueWatch' -count=1
  • go test ./tests/integration/ -run '^TestAPIIssueSubscriptions$' -count=1

Coverage notes

  • Unit: issue1 expects poster + commenter + repo watchers (inactive/Dont excluded); issue7 expects only explicit watcher (explicit unsubscriber excluded)
  • Integration: list endpoint matches that set; after explicit unsubscribe, user is removed while other effective subscribers remain

AI disclosure

Assisted by Hermes (grok-4.5) for diagnosis, implementation, and tests. Changes reviewed and verified locally.

GET /repos/{owner}/{repo}/issues/{index}/subscriptions previously only
returned rows from issue_watch with is_watching=true. The web UI and
notification path treat participants (commenters/author) and repo
watchers as subscribed unless explicitly unsubscribed, so the API
list was incomplete and inconsistent with /subscriptions/check.

Return the same effective subscriber set: explicit watchers ∪
participants ∪ issue author ∪ repo watchers (normal/auto), minus
explicit unsubscribers, filtering inactive/prohibited users.

Fixes go-gitea#26750

Assisted-by: hermes:grok-4.5
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 27, 2026
@github-actions github-actions Bot added topic/api Concerns mainly the API type/bug labels Jul 27, 2026
@majorissuerep

Copy link
Copy Markdown
Contributor Author

Issue #26750 updated with the effective-subscriber contract this PR implements. Current set matches CheckIssueWatch / UI unsubscribe. Can keep explicit-watch-only behind a query flag if that's preferred.

Assisted-by: Hermes:glm-5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. topic/api Concerns mainly the API type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue subscription API will not return all participants

2 participants