-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Prevent sending emails and notifications to inactive users #2384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
22537f0
d08001f
76aace8
9bcaa0d
669b5df
fdc0f6c
7047786
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
num_pulls: 2 | ||
num_closed_pulls: 0 | ||
num_milestones: 2 | ||
num_watches: 2 | ||
num_watches: 3 | ||
|
||
- | ||
id: 2 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,8 @@ | |
id: 2 | ||
user_id: 4 | ||
repo_id: 1 | ||
|
||
- | ||
id: 3 | ||
user_id: 10 | ||
repo_id: 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2017 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package migrations | ||
|
||
import ( | ||
"fmt" | ||
|
||
"code.gitea.io/gitea/models" | ||
|
||
"github.com/go-xorm/xorm" | ||
) | ||
|
||
func addDefaultValueToUserProhibitLogin(x *xorm.Engine) (err error) { | ||
user := &models.User{ | ||
ProhibitLogin: false, | ||
} | ||
|
||
if _, err := x.Where("`prohibit_login` IS NULL").Cols("prohibit_login").Update(user); err != nil { | ||
return err | ||
} | ||
|
||
dialect := x.Dialect().DriverName() | ||
|
||
switch dialect { | ||
case "mysql": | ||
_, err = x.Exec("ALTER TABLE user MODIFY `prohibit_login` tinyint(1) NOT NULL DEFAULT 0") | ||
case "postgres": | ||
_, err = x.Exec("ALTER TABLE \"user\" ALTER COLUMN `prohibit_login` SET NOT NULL, ALTER COLUMN `prohibit_login` SET DEFAULT false") | ||
case "mssql": | ||
// xorm already set DEFAULT 0 for data type BIT in mssql | ||
_, err = x.Exec(`ALTER TABLE [user] ALTER COLUMN "prohibit_login" BIT NOT NULL`) | ||
case "sqlite3": | ||
} | ||
|
||
if err != nil { | ||
return fmt.Errorf("Error changing user prohibit_login column definition: %v", err) | ||
} | ||
|
||
return err | ||
} |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -51,7 +51,11 @@ func WatchRepo(userID, repoID int64, watch bool) (err error) { | |||
|
||||
func getWatchers(e Engine, repoID int64) ([]*Watch, error) { | ||||
watches := make([]*Watch, 0, 10) | ||||
return watches, e.Find(&watches, &Watch{RepoID: repoID}) | ||||
return watches, e.Where("`watch`.repo_id=?", repoID). | ||||
And("`user`.is_active=?", true). | ||||
And("`user`.prohibit_login=?", false). | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think user who is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method is also used in Line 104 in f61a1d2
Perhaps I should add a second method or a parameter to add restriction conditionally? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, add additional parameter to function to know in to return all as it was or just active ones There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lunny @lafriks I figured out that the view isn't using this method anyways. The view is using the method from here https://github.com/daviian/gitea/blob/e3f679f39da7985193cec28a7c21fbc16ab2310d/models/repo_watch.go#L67 The method in question is only used by notification and mail There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lunny Any response? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @daviian OK. |
||||
Join("INNER", "user", "`user`.id = `watch`.user_id"). | ||||
Find(&watches) | ||||
} | ||||
|
||||
// GetWatchers returns all watchers of given repository. | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing testing in this patch?.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@appleboy what do you mean?