-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Email alerts #287
Email alerts #287
Conversation
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.
Code's good, thank you.
There are some small changes. The code for templates looks ok.
} | ||
|
||
func (t *task) sendMailAlert() { | ||
|
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.
this code block (not specific to Go) could be rewritten to be more readable
Example:
if true {
do something
} else {
do the other stuff
}
Could be rewritten to be more expressive as:
if false {
do something
return
}
do the other stuff
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.
fixed
api/tasks/alert.go
Outdated
} | ||
} | ||
} else { | ||
t.log("Alerts disabled for this project, nothing to do.") |
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.
if alerts are disabled, there's no need to log them :)
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.
fixed
public/html/projects/edit.pug
Outdated
@@ -7,8 +7,12 @@ form.form-horizontal | |||
input.form-control(type="text" ng-model="projectName" placeholder="Project Name") | |||
|
|||
.form-group | |||
label.control-label.col-sm-4 Allow alerts for this project | |||
.col-sm-1: input.form-control(type="checkbox" title="Send email alerts about failed tasks" ng-model="alert") |
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.
See the docs for checkboxes in bootstrap: .checkbox
class
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.
made it a bit less ugly
util/config.go
Outdated
@@ -182,4 +191,44 @@ func (conf *configType) Scan() { | |||
conf.TmpPath = "/tmp/semaphore" | |||
} | |||
conf.TmpPath = path.Clean(conf.TmpPath) | |||
|
|||
var alertanswer string | |||
fmt.Print(" > Do you need an email alerts (y/n, default n): ") |
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.
change to > Enable email alerts (y/n, default n):
please
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.
fixed
util/mail.go
Outdated
"net/smtp" | ||
) | ||
|
||
func SendMail(emailHost string, mailSender string, mailRecipient string, mail bytes.Buffer) error { |
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.
tip: func SendMail (emailHost, mailSender, mailRecipient string, mail bytes.Buffer) error {
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.
fixed
@@ -0,0 +1,2 @@ | |||
ALTER TABLE user ADD alert BOOLEAN NOT NULL AFTER password; |
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.
not sure if BOOLEAN
type is new, check compatibility with versions of mysql/mariadb listed in wiki
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.
BOOLEAN
supported at least since MySQL 5.5 - https://dev.mysql.com/doc/refman/5.5/en/numeric-type-overview.html
@matejkramny Thank you for the review! I'll update my PR soon. |
Changes are made. One question: should I provide some documentation and where should I put it? In the Wiki? |
Hmm there's no documentation (aside from the swagger API spec). If there are any API changes, put it in the swagger document |
done |
Awesome, thanks! |
See #269
Please, look precisely to migration and to api/tasks/alert.go (especially on work with template - I think this code can be better, but my Golang-fu isn't perfect :( ).