Fix shadowed variables in various places: Part 2 of 2 (#10176)

This PR fixes shadowed variables in the following packages:
- `app`
- `utils`
- `utils/markdown`
- `services/mailservice`
Этот коммит содержится в:
Hanzei
2019-01-28 21:57:45 +01:00
коммит произвёл GitHub
родитель 58b2a3d16e
Коммит 179e98c245
7 изменённых файлов: 26 добавлений и 22 удалений

Просмотреть файл

@@ -89,8 +89,7 @@ func GetMailBox(email string) (results JSONMessageHeaderInbucket, err error) {
return record, nil
}
func GetMessageFromMailbox(email, id string) (results JSONMessageInbucket, err error) {
func GetMessageFromMailbox(email, id string) (JSONMessageInbucket, error) {
parsedEmail := ParseEmail(email)
var record JSONMessageInbucket
@@ -102,17 +101,20 @@ func GetMessageFromMailbox(email, id string) (results JSONMessageInbucket, err e
}
defer emailResponse.Body.Close()
err = json.NewDecoder(emailResponse.Body).Decode(&record)
if err = json.NewDecoder(emailResponse.Body).Decode(&record); err != nil {
return record, err
}
// download attachments
if record.Attachments != nil && len(record.Attachments) > 0 {
for i := range record.Attachments {
if bytes, err := downloadAttachment(record.Attachments[i].DownloadLink); err != nil {
var bytes []byte
bytes, err = downloadAttachment(record.Attachments[i].DownloadLink)
if err != nil {
return record, err
} else {
record.Attachments[i].Bytes = make([]byte, len(bytes))
copy(record.Attachments[i].Bytes, bytes)
}
record.Attachments[i].Bytes = make([]byte, len(bytes))
copy(record.Attachments[i].Bytes, bytes)
}
}

Просмотреть файл

@@ -136,7 +136,7 @@ func NewSMTPClientAdvanced(conn net.Conn, hostname string, connectionInfo *SmtpC
}
if hostname != "" {
err := c.Hello(hostname)
err = c.Hello(hostname)
if err != nil {
mlog.Error(fmt.Sprintf("Failed to to set the HELO to SMTP server %v", err))
return nil, model.NewAppError("SendMail", "utils.mail.connect_smtp.helo.app_error", nil, err.Error(), http.StatusInternalServerError)
@@ -273,11 +273,11 @@ func SendMail(c *smtp.Client, mimeTo, smtpTo string, from mail.Address, subject,
}))
}
if err := c.Mail(from.Address); err != nil {
if err = c.Mail(from.Address); err != nil {
return model.NewAppError("SendMail", "utils.mail.send_mail.from_address.app_error", nil, err.Error(), http.StatusInternalServerError)
}
if err := c.Rcpt(smtpTo); err != nil {
if err = c.Rcpt(smtpTo); err != nil {
return model.NewAppError("SendMail", "utils.mail.send_mail.to_address.app_error", nil, err.Error(), http.StatusInternalServerError)
}