Order attachments by creation date when new post is created

This commit is contained in:
silverpill 2023-03-31 19:23:20 +00:00
parent 9a32fb9c80
commit dbca8183bb
2 changed files with 3 additions and 1 deletions

View file

@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Process queued background jobs before re-trying stalled.
- Remove activity from queue if handler times out.
- Order attachments by creation date when new post is created.
## [1.19.0] - 2023-03-30

View file

@ -57,9 +57,10 @@ async fn create_post_attachments(
// Some attachments were not found
return Err(DatabaseError::NotFound("attachment"));
};
let attachments = attachments_rows.iter()
let mut attachments: Vec<DbMediaAttachment> = attachments_rows.iter()
.map(|row| row.try_get("media_attachment"))
.collect::<Result<_, _>>()?;
attachments.sort_by(|a, b| a.created_at.cmp(&b.created_at));
Ok(attachments)
}