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
|
FROM messages m
|
||||||
JOIN users u ON m.author_id = u.id
|
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)
|
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
|
LIMIT $3
|
||||||
`, channelID, before, limit)
|
`, channelID, before, limit)
|
||||||
} else {
|
} else {
|
||||||
@@ -320,7 +320,7 @@ func (h *Handler) List(w http.ResponseWriter, r *http.Request) {
|
|||||||
FROM messages m
|
FROM messages m
|
||||||
JOIN users u ON m.author_id = u.id
|
JOIN users u ON m.author_id = u.id
|
||||||
WHERE m.channel_id = $1
|
WHERE m.channel_id = $1
|
||||||
ORDER BY m.created_at DESC
|
ORDER BY m.created_at ASC
|
||||||
LIMIT $2
|
LIMIT $2
|
||||||
`, channelID, limit)
|
`, channelID, limit)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user