mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 11:21:02 +00:00
Forgot to add file.
This commit is contained in:
parent
9e0b91d39a
commit
42eaa20a87
1 changed files with 25 additions and 0 deletions
25
crates/api/src/site/list_all_media.rs
Normal file
25
crates/api/src/site/list_all_media.rs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
use actix_web::web::{Data, Json, Query};
|
||||||
|
use lemmy_api_common::{
|
||||||
|
context::LemmyContext,
|
||||||
|
person::{ListMedia, ListMediaResponse},
|
||||||
|
utils::is_admin,
|
||||||
|
};
|
||||||
|
use lemmy_db_schema::source::images::LocalImage;
|
||||||
|
use lemmy_db_views::structs::LocalUserView;
|
||||||
|
use lemmy_utils::error::LemmyError;
|
||||||
|
|
||||||
|
/// Lists comment reports for a community iooo
|
||||||
|
#[tracing::instrument(skip(context))]
|
||||||
|
pub async fn list_all_media(
|
||||||
|
data: Query<ListMedia>,
|
||||||
|
context: Data<LemmyContext>,
|
||||||
|
local_user_view: LocalUserView,
|
||||||
|
) -> Result<Json<ListMediaResponse>, LemmyError> {
|
||||||
|
// Only let admins view all media
|
||||||
|
is_admin(&local_user_view)?;
|
||||||
|
|
||||||
|
let page = data.page;
|
||||||
|
let limit = data.limit;
|
||||||
|
let images = LocalImage::get_all(&mut context.pool(), page, limit).await?;
|
||||||
|
Ok(Json(ListMediaResponse { images }))
|
||||||
|
}
|
Loading…
Reference in a new issue