Skip to content

Commit

Permalink
backend: Return local files too
Browse files Browse the repository at this point in the history
  • Loading branch information
pbzweihander committed May 18, 2024
1 parent 003bef7 commit 7506269
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions backend/src/dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ impl Post {
.await
.context_internal_server_error("failed to query database")?;

let local_files = post
.find_related(local_file::Entity)
.order_by_asc(local_file::Column::Order)
.all(db)
.await
.context_internal_server_error("failed to query database")?;

let files = remote_files
.into_iter()
.filter_map(|file| {
Expand All @@ -275,6 +282,13 @@ impl Post {
alt: file.alt,
})
})
.chain(local_files.into_iter().filter_map(|file| {
Some(File {
media_type: file.media_type.parse().ok()?,
url: file.url.parse().ok()?,
alt: file.alt,
})
}))
.collect::<Vec<_>>();

let reactions = reaction::Entity::find()
Expand Down

0 comments on commit 7506269

Please sign in to comment.