aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/app/message/show.go')
-rw-r--r--pkg/app/message/show.go22
1 files changed, 5 insertions, 17 deletions
diff --git a/pkg/app/message/show.go b/pkg/app/message/show.go
index 3d56544..60038d5 100644
--- a/pkg/app/message/show.go
+++ b/pkg/app/message/show.go
@@ -17,33 +17,21 @@ func Show(w http.ResponseWriter, r *http.Request) {
messageHash := urlParts[len(urlParts)-1]
message := &models.Message{Id: messageHash}
- err := database.DBCon.Select(message)
+ err := database.DBCon.Model(message).
+ Relation("InReplyTo").
+ WherePK().
+ Select()
if err != nil {
http.NotFound(w, r)
return
}
- var inReplyTos []*models.Message
- var inReplyTo *models.Message
- if message.InReplyTo != nil {
- err = database.DBCon.Model(&inReplyTos).
- Where(`(headers::jsonb->>'Message-Id')::jsonb ? '` + message.InReplyTo.Id + `'`).
- Select()
- if err != nil || len(inReplyTos) < 1 {
- inReplyTo = nil
- } else {
- inReplyTo = inReplyTos[0]
- }
- } else {
- inReplyTo = nil
- }
-
var replies []*models.Message
database.DBCon.Model(&replies).
Where(`(headers::jsonb->>'References')::jsonb ? '` + message.Id + `'`).
WhereOr(`(headers::jsonb->>'In-Reply-To')::jsonb ? '` + message.Id + `'`).
Order("date ASC").Select()
- renderMessageTemplate(w, listName, message, inReplyTo, replies)
+ renderMessageTemplate(w, listName, message, replies)
}