Skip to content

Commit 26359ba

Browse files
committed
Firmed up some nill checks
1 parent ad73811 commit 26359ba

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

app/handlers/feed.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ func CommentFeed() web.HandlerFunc {
237237
if err := bus.Dispatch(c, getPost); err != nil {
238238
return c.Failure(err)
239239
}
240+
241+
if getPost.Result == nil {
242+
return c.NotFound()
243+
}
244+
240245
getComments := &query.GetCommentsByPost{Post: getPost.Result}
241246
if err := bus.Dispatch(c, getComments); err != nil {
242247
return c.Failure(err)
@@ -245,10 +250,15 @@ func CommentFeed() web.HandlerFunc {
245250
comments := getComments.Result
246251
comments = comments[max(0, len(comments)-30):] // get the last 30 comments
247252

253+
authorName := ""
254+
if post.User != nil {
255+
authorName = post.User.Name
256+
}
257+
248258
feed := &AtomFeed{
249259
Title: post.Title,
250260
Subtitle: Content{Body: string(markdown.Full(post.Description, true)), Type: "html"},
251-
Author: &Author{Name: post.User.Name},
261+
Author: &Author{Name: authorName},
252262
Id: fmt.Sprintf("%s/posts/%d/#comments", web.BaseURL(c), post.Number),
253263
Link: []Link{
254264
{Href: fmt.Sprintf("%s/feed/posts/%d.atom", web.BaseURL(c), post.Number), Type: "application/atom+xml", Rel: "self"},

0 commit comments

Comments
 (0)