mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-05-09 13:32:39 +00:00
6bfbb9332d
* Adding listMedia endpoint, to view all your local image uploads. - Fixes #4445 * Fix ts import. * Forgot to order by published desc * Adding an endpoint to list all images, for admins only. * Forgot to add file. * Add additional test. * Use better logic for no-limit version. * Better call sites. * Adding another test. * Fix tests. * Moving list_media to /account action. * Addressing PR comments. * Removing pointless comment. --------- Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com>
27 lines
718 B
Rust
27 lines
718 B
Rust
use actix_web::web::{Data, Json, Query};
|
|
use lemmy_api_common::{
|
|
context::LemmyContext,
|
|
person::{ListMedia, ListMediaResponse},
|
|
};
|
|
use lemmy_db_schema::source::images::LocalImage;
|
|
use lemmy_db_views::structs::LocalUserView;
|
|
use lemmy_utils::error::LemmyError;
|
|
|
|
#[tracing::instrument(skip(context))]
|
|
pub async fn list_media(
|
|
data: Query<ListMedia>,
|
|
context: Data<LemmyContext>,
|
|
local_user_view: LocalUserView,
|
|
) -> Result<Json<ListMediaResponse>, LemmyError> {
|
|
let page = data.page;
|
|
let limit = data.limit;
|
|
let images = LocalImage::get_all_paged_by_local_user_id(
|
|
&mut context.pool(),
|
|
local_user_view.local_user.id,
|
|
page,
|
|
limit,
|
|
)
|
|
.await?;
|
|
Ok(Json(ListMediaResponse { images }))
|
|
}
|