fix: return messages in chronological order (oldest first)

This commit is contained in:
2026-06-29 14:18:56 -04:00
parent 175ec90705
commit c189bd2d83
+2 -2
View File
@@ -311,7 +311,7 @@ func (h *Handler) List(w http.ResponseWriter, r *http.Request) {
FROM messages m
JOIN users u ON m.author_id = u.id
WHERE m.channel_id = $1 AND m.created_at < (SELECT created_at FROM messages WHERE id = $2)
ORDER BY m.created_at DESC
ORDER BY m.created_at ASC
LIMIT $3
`, channelID, before, limit)
} else {
@@ -320,7 +320,7 @@ func (h *Handler) List(w http.ResponseWriter, r *http.Request) {
FROM messages m
JOIN users u ON m.author_id = u.id
WHERE m.channel_id = $1
ORDER BY m.created_at DESC
ORDER BY m.created_at ASC
LIMIT $2
`, channelID, limit)
}