Fix crash in GetTopicWithAvatar().

This commit is contained in:
hsluoyz 2022-01-30 00:17:59 +08:00
parent 9416b80297
commit f3ff00d2d6
1 changed files with 10 additions and 3 deletions

View File

@ -231,10 +231,14 @@ func GetTopicWithAvatar(id int, user *auth.User) *TopicWithAvatar {
go func() {
defer wg.Done()
topic.Topic = *GetTopic(id)
topic.Avatar = getUserAvatar(topic.Author)
topicObj := GetTopic(id)
if topicObj != nil {
topic.Topic = *topicObj
topic.Editable = GetTopicEditableStatus(user, topic.Author, topic.NodeId, topic.CreatedTime)
topic.Avatar = getUserAvatar(topic.Author)
topic.Editable = GetTopicEditableStatus(user, topic.Author, topic.NodeId, topic.CreatedTime)
}
}()
go func() {
defer wg.Done()
@ -248,6 +252,9 @@ func GetTopicWithAvatar(id int, user *auth.User) *TopicWithAvatar {
wg.Wait()
if topic.Author == "" {
return nil
}
return &topic
}