From d8ec39ca028dfed3e2c1ba0193c6fde977ae22b5 Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Tue, 29 Jun 2021 17:20:43 -0700 Subject: check for nil pointer reference --- client.go | 11 ++++++----- main.go | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client.go b/client.go index 97222d1..cfa6b7f 100644 --- a/client.go +++ b/client.go @@ -224,12 +224,13 @@ func PostGet(w http.ResponseWriter, r *http.Request, db *sql.DB){ } } else { collection := GetObjectByIDFromDB(db, inReplyTo) + if collection.Actor != nil { + returnData.Board.Post.Actor = collection.Actor.Id + returnData.Board.InReplyTo = inReplyTo - returnData.Board.Post.Actor = collection.Actor.Id - returnData.Board.InReplyTo = inReplyTo - - if len(collection.OrderedItems) > 0 { - returnData.Posts = append(returnData.Posts, collection.OrderedItems[0]) + if len(collection.OrderedItems) > 0 { + returnData.Posts = append(returnData.Posts, collection.OrderedItems[0]) + } } } diff --git a/main.go b/main.go index 758436c..76da453 100644 --- a/main.go +++ b/main.go @@ -2425,7 +2425,6 @@ func GetActorInstance(path string) (string, string) { } func AddInstanceToIndex(actor string) { - // if local testing enviroment do not add to index re := regexp.MustCompile(`(.+)?(localhost|\d+\.\d+\.\d+\.\d+)(.+)?`) if re.MatchString(actor) { -- cgit v1.2.3