Skip to content
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

fix logic of detecting deprecated notify type params #1279

Merged
merged 1 commit into from
Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions backend/app/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,9 @@ func (s *ServerCommand) HandleDeprecatedFlags() (result []DeprecatedFlag) {
s.ImageProxy.HTTP2HTTPS = s.LegacyImageProxy
result = append(result, DeprecatedFlag{Old: "img-proxy", New: "image-proxy.http2https", Version: "1.5"})
}
if len(s.Notify.Type) != 0 && // explicitly empty, would likely never happen due to "none" default
!(len(s.Notify.Type) == 1 && contains("none", s.Notify.Type)) && // ignore default, "none" notify type
(len(s.Notify.Users) != 0 || len(s.Notify.Admins) != 0) { // new notify param(s) are used, safe to ignore the old one
if !contains("none", s.Notify.Type) &&
contains("none", s.Notify.Users) &&
contains("none", s.Notify.Admins) { // if new notify param(s) are used, safe to ignore the old one
s.handleDeprecatedNotifications()
result = append(result, DeprecatedFlag{Old: "notify.type", New: "notify.(users|admins)", Version: "1.9"})
}
Expand Down Expand Up @@ -404,8 +404,8 @@ func (s *ServerCommand) findDeprecatedFlagsCollisions() (result []DeprecatedFlag
if s.Auth.Email.TimeOut != emailDefaultTimout && s.SMTP.TimeOut != emailDefaultTimout && s.Auth.Email.TimeOut != s.SMTP.TimeOut {
result = append(result, DeprecatedFlag{Old: "auth.email.timeout", New: "smtp.timeout", Collision: true})
}
if !(len(s.Notify.Type) == 1 && contains("none", s.Notify.Type)) && // default, "none" notify type
(len(s.Notify.Users) != 0 || len(s.Notify.Admins) != 0) { // new notify param(s) are used, old ones will be ignored
if !contains("none", s.Notify.Type) &&
(!contains("none", s.Notify.Users) || !contains("none", s.Notify.Admins)) {
result = append(result, DeprecatedFlag{Old: "notify.type", New: "notify.(users|admins)", Collision: true})
}
if stringsSetAndDifferent(s.Notify.Telegram.Token, s.Telegram.Token) {
Expand Down
4 changes: 3 additions & 1 deletion backend/app/cmd/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ func TestServerApp_DeprecatedArgs(t *testing.T) {
"test",
"--notify.type=email",
"--notify.type=telegram",
"--notify.users=none",
"--notify.admins=none",
"--img-proxy",
"--notify.email.notify_admin",
"--auth.email.host=smtp.example.org",
Expand Down Expand Up @@ -446,7 +448,6 @@ func TestServerApp_DeprecatedArgs(t *testing.T) {
{Old: "img-proxy", New: "image-proxy.http2https", Version: "1.5"},
{Old: "notify.email.notify_admin", New: "notify.admins=email", Version: "1.9"},
{Old: "notify.type", New: "notify.(users|admins)", Version: "1.9"},
{Old: "notify.type", New: "notify.(users|admins)", Collision: true},
{Old: "notify.telegram.token", New: "telegram.token", Version: "1.9"},
{Old: "notify.telegram.timeout", New: "telegram.timeout", Version: "1.9"},
{Old: "notify.telegram.api", Version: "1.9"},
Expand Down Expand Up @@ -479,6 +480,7 @@ func TestServerApp_DeprecatedArgsCollisions(t *testing.T) {
"--smtp.timeout=20s",
"--notify.type=telegram",
"--notify.users=telegram",
"--notify.admins=none",
"--notify.telegram.token=abcd",
"--telegram.token=dcba",
"--notify.telegram.timeout=3m",
Expand Down