mirror of
https://github.com/LemmyNet/lemmy
synced 2024-10-30 15:21:20 +00:00
6efab9aab1
* Creating a LocalImageView, so that front ends have the Person struct. * Removing local_user from LocalImageView. * Add uploader check.
26 lines
685 B
Rust
26 lines
685 B
Rust
use actix_web::web::{Data, Json, Query};
|
|
use lemmy_api_common::{
|
|
context::LemmyContext,
|
|
person::{ListMedia, ListMediaResponse},
|
|
};
|
|
use lemmy_db_views::structs::{LocalImageView, LocalUserView};
|
|
use lemmy_utils::error::LemmyResult;
|
|
|
|
#[tracing::instrument(skip(context))]
|
|
pub async fn list_media(
|
|
data: Query<ListMedia>,
|
|
context: Data<LemmyContext>,
|
|
local_user_view: LocalUserView,
|
|
) -> LemmyResult<Json<ListMediaResponse>> {
|
|
let page = data.page;
|
|
let limit = data.limit;
|
|
let images = LocalImageView::get_all_paged_by_local_user_id(
|
|
&mut context.pool(),
|
|
local_user_view.local_user.id,
|
|
page,
|
|
limit,
|
|
)
|
|
.await?;
|
|
Ok(Json(ListMediaResponse { images }))
|
|
}
|