Skip to content

Commit 9406368

Browse files
6543zeripath
authored andcommitted
Fix Issue Unsubscription (#9634)
1 parent b6fa229 commit 9406368

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

models/issue_watch.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
package models
66

7-
import "code.gitea.io/gitea/modules/timeutil"
7+
import (
8+
"code.gitea.io/gitea/modules/timeutil"
9+
)
810

911
// IssueWatch is connection request for receiving issue notification.
1012
type IssueWatch struct {
@@ -46,17 +48,18 @@ func CreateOrUpdateIssueWatch(userID, issueID int64, isWatching bool) error {
4648
return nil
4749
}
4850

49-
// GetIssueWatch returns an issue watch by user and issue
51+
// GetIssueWatch returns all IssueWatch objects from db by user and issue
52+
// the current Web-UI need iw object for watchers AND explicit non-watchers
5053
func GetIssueWatch(userID, issueID int64) (iw *IssueWatch, exists bool, err error) {
5154
return getIssueWatch(x, userID, issueID)
5255
}
5356

57+
// Return watcher AND explicit non-watcher if entry in db exist
5458
func getIssueWatch(e Engine, userID, issueID int64) (iw *IssueWatch, exists bool, err error) {
5559
iw = new(IssueWatch)
5660
exists, err = e.
5761
Where("user_id = ?", userID).
5862
And("issue_id = ?", issueID).
59-
And("is_watching = ?", true).
6063
Get(iw)
6164
return
6265
}

models/issue_watch_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ func TestGetIssueWatch(t *testing.T) {
2929
assert.True(t, exists)
3030
assert.NoError(t, err)
3131

32-
_, exists, err = GetIssueWatch(2, 2)
33-
assert.False(t, exists)
32+
iw, exists, err := GetIssueWatch(2, 2)
33+
assert.True(t, exists)
3434
assert.NoError(t, err)
35+
assert.EqualValues(t, false, iw.IsWatching)
3536

3637
_, exists, err = GetIssueWatch(3, 1)
3738
assert.False(t, exists)

0 commit comments

Comments
 (0)