Add debug log for nil referencedPost (#18437)

* add debug log for nil post

* add post id for context

* log other vars that may be nil

* change from Warn to Debug
This commit is contained in:
Michael Kochell
2021-09-21 18:44:03 -04:00
committed by GitHub
parent 0c84885132
commit e575315275

View File

@@ -5,6 +5,7 @@ package app
import (
"bytes"
"errors"
"fmt"
"image"
"io"
@@ -490,16 +491,34 @@ func (a *App) getLinkMetadata(requestURL string, timestamp int64, isNewPost bool
return nil, nil, nil, appErr
}
if referencedPost == nil {
msg := "Referenced post is nil"
mlog.Debug(msg, mlog.String("post_id", referencedPostID))
return nil, nil, nil, errors.New(msg)
}
referencedChannel, appErr := a.GetChannel(referencedPost.ChannelId)
if appErr != nil {
return nil, nil, nil, appErr
}
if referencedChannel == nil {
msg := "Referenced channel is nil"
mlog.Debug(msg, mlog.String("channel_id", referencedPost.ChannelId))
return nil, nil, nil, errors.New(msg)
}
referencedTeam, appErr := a.GetTeam(referencedChannel.TeamId)
if appErr != nil {
return nil, nil, nil, appErr
}
if referencedTeam == nil {
msg := "Referenced team is nil"
mlog.Debug(msg, mlog.String("team_id", referencedChannel.TeamId))
return nil, nil, nil, errors.New(msg)
}
permalink = &model.Permalink{PreviewPost: model.NewPreviewPost(referencedPost, referencedTeam, referencedChannel)}
} else {