mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-04 10:11:21 +00:00
6efab9aab1
* Creating a LocalImageView, so that front ends have the Person struct. * Removing local_user from LocalImageView. * Add uploader check.
23 lines
698 B
Rust
23 lines
698 B
Rust
use actix_web::web::{Data, Json, Query};
|
|
use lemmy_api_common::{
|
|
context::LemmyContext,
|
|
person::{ListMedia, ListMediaResponse},
|
|
utils::is_admin,
|
|
};
|
|
use lemmy_db_views::structs::{LocalImageView, LocalUserView};
|
|
use lemmy_utils::error::LemmyResult;
|
|
|
|
#[tracing::instrument(skip(context))]
|
|
pub async fn list_all_media(
|
|
data: Query<ListMedia>,
|
|
context: Data<LemmyContext>,
|
|
local_user_view: LocalUserView,
|
|
) -> LemmyResult<Json<ListMediaResponse>> {
|
|
// Only let admins view all media
|
|
is_admin(&local_user_view)?;
|
|
|
|
let page = data.page;
|
|
let limit = data.limit;
|
|
let images = LocalImageView::get_all(&mut context.pool(), page, limit).await?;
|
|
Ok(Json(ListMediaResponse { images }))
|
|
}
|