mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-52922] Fix a possible nil call to subscription.LastInvoice (#23540)
Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
parent
a9645b634a
commit
cbfc14b2b4
@ -198,12 +198,17 @@ func (a *App) SendUpgradeConfirmationEmail(isYearly bool) *model.AppError {
|
||||
|
||||
embeddedFiles := make(map[string]io.Reader)
|
||||
if isYearly {
|
||||
pdf, filename, pdfErr := a.Cloud().GetInvoicePDF("", subscription.LastInvoice.ID)
|
||||
if pdfErr != nil {
|
||||
a.Log().Error("Error retrieving the invoice for subscription id", mlog.String("subscription", subscription.ID), mlog.Err(pdfErr))
|
||||
lastInvoice := subscription.LastInvoice
|
||||
if lastInvoice == nil {
|
||||
a.Log().Error("Last invoice not defined for the subscription", mlog.String("subscription", subscription.ID))
|
||||
} else {
|
||||
embeddedFiles = map[string]io.Reader{
|
||||
filename: bytes.NewReader(pdf),
|
||||
pdf, filename, pdfErr := a.Cloud().GetInvoicePDF("", lastInvoice.ID)
|
||||
if pdfErr != nil {
|
||||
a.Log().Error("Error retrieving the invoice for subscription id", mlog.String("subscription", subscription.ID), mlog.Err(pdfErr))
|
||||
} else {
|
||||
embeddedFiles = map[string]io.Reader{
|
||||
filename: bytes.NewReader(pdf),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user