mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Prevent sending emails and notifications to inactive users (#2384)
* Filter inactive users before sending emails or creating browser notifications Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com> * fix formatting issues Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com> * included requested changes Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com> * optimized database queries * rebasing new master and add tablenames for clarification in xorm queries * remove escaped quotationmarks using backticks Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
This commit is contained in:
committed by
Lunny Xiao
parent
b496e3e1cc
commit
d766d0c4e0
@@ -40,7 +40,8 @@ func TestGetWatchers(t *testing.T) {
|
||||
repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
|
||||
watches, err := GetWatchers(repo.ID)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, watches, repo.NumWatches)
|
||||
// Two watchers are inactive, thus minus 2
|
||||
assert.Len(t, watches, repo.NumWatches-2)
|
||||
for _, watch := range watches {
|
||||
assert.EqualValues(t, repo.ID, watch.RepoID)
|
||||
}
|
||||
@@ -77,22 +78,17 @@ func TestNotifyWatchers(t *testing.T) {
|
||||
}
|
||||
assert.NoError(t, NotifyWatchers(action))
|
||||
|
||||
AssertExistsAndLoadBean(t, &Action{
|
||||
ActUserID: action.ActUserID,
|
||||
UserID: 1,
|
||||
RepoID: action.RepoID,
|
||||
OpType: action.OpType,
|
||||
})
|
||||
AssertExistsAndLoadBean(t, &Action{
|
||||
ActUserID: action.ActUserID,
|
||||
UserID: 4,
|
||||
RepoID: action.RepoID,
|
||||
OpType: action.OpType,
|
||||
})
|
||||
// Two watchers are inactive, thus action is only created for user 8, 10
|
||||
AssertExistsAndLoadBean(t, &Action{
|
||||
ActUserID: action.ActUserID,
|
||||
UserID: 8,
|
||||
RepoID: action.RepoID,
|
||||
OpType: action.OpType,
|
||||
})
|
||||
AssertExistsAndLoadBean(t, &Action{
|
||||
ActUserID: action.ActUserID,
|
||||
UserID: 10,
|
||||
RepoID: action.RepoID,
|
||||
OpType: action.OpType,
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user