mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-03 00:45:22 +02: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:
parent
b496e3e1cc
commit
d766d0c4e0
13 changed files with 89 additions and 25 deletions
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue