fix: return messages in chronological order (oldest first)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user