mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-25 22:01:19 +00:00
Adding an endpoint to list all images, for admins only.
This commit is contained in:
parent
3eae5b9d9b
commit
9e0b91d39a
4 changed files with 20 additions and 2 deletions
|
@ -7,8 +7,6 @@ use lemmy_db_schema::source::images::LocalImage;
|
||||||
use lemmy_db_views::structs::LocalUserView;
|
use lemmy_db_views::structs::LocalUserView;
|
||||||
use lemmy_utils::error::LemmyError;
|
use lemmy_utils::error::LemmyError;
|
||||||
|
|
||||||
/// Lists comment reports for a community if an id is supplied
|
|
||||||
/// or returns all comment reports for communities a user moderates
|
|
||||||
#[tracing::instrument(skip(context))]
|
#[tracing::instrument(skip(context))]
|
||||||
pub async fn list_media(
|
pub async fn list_media(
|
||||||
data: Query<ListMedia>,
|
data: Query<ListMedia>,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
pub mod block;
|
pub mod block;
|
||||||
pub mod federated_instances;
|
pub mod federated_instances;
|
||||||
pub mod leave_admin;
|
pub mod leave_admin;
|
||||||
|
pub mod list_all_media;
|
||||||
pub mod mod_log;
|
pub mod mod_log;
|
||||||
pub mod purge;
|
pub mod purge;
|
||||||
pub mod registration_applications;
|
pub mod registration_applications;
|
||||||
|
|
|
@ -49,6 +49,23 @@ impl LocalImage {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_all(
|
||||||
|
pool: &mut DbPool<'_>,
|
||||||
|
page: Option<i64>,
|
||||||
|
limit: Option<i64>,
|
||||||
|
) -> Result<Vec<Self>, Error> {
|
||||||
|
let conn = &mut get_conn(pool).await?;
|
||||||
|
let (limit, offset) = limit_and_offset(page, limit)?;
|
||||||
|
|
||||||
|
local_image::table
|
||||||
|
.select(local_image::all_columns)
|
||||||
|
.order_by(local_image::published.desc())
|
||||||
|
.limit(limit)
|
||||||
|
.offset(offset)
|
||||||
|
.load::<LocalImage>(conn)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn delete_by_alias(pool: &mut DbPool<'_>, alias: &str) -> Result<usize, Error> {
|
pub async fn delete_by_alias(pool: &mut DbPool<'_>, alias: &str) -> Result<usize, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::delete(local_image::table.filter(local_image::pictrs_alias.eq(alias)))
|
diesel::delete(local_image::table.filter(local_image::pictrs_alias.eq(alias)))
|
||||||
|
|
|
@ -72,6 +72,7 @@ use lemmy_api::{
|
||||||
block::block_instance,
|
block::block_instance,
|
||||||
federated_instances::get_federated_instances,
|
federated_instances::get_federated_instances,
|
||||||
leave_admin::leave_admin,
|
leave_admin::leave_admin,
|
||||||
|
list_all_media::list_all_media,
|
||||||
mod_log::get_mod_log,
|
mod_log::get_mod_log,
|
||||||
purge::{
|
purge::{
|
||||||
comment::purge_comment,
|
comment::purge_comment,
|
||||||
|
@ -341,6 +342,7 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
||||||
"/registration_application/approve",
|
"/registration_application/approve",
|
||||||
web::put().to(approve_registration_application),
|
web::put().to(approve_registration_application),
|
||||||
)
|
)
|
||||||
|
.route("/list_media", web::get().to(list_all_media))
|
||||||
.service(
|
.service(
|
||||||
web::scope("/purge")
|
web::scope("/purge")
|
||||||
.route("/person", web::post().to(purge_person))
|
.route("/person", web::post().to(purge_person))
|
||||||
|
|
Loading…
Reference in a new issue