mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-12 11:06:32 +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>
153 lines
4.6 KiB
Rust
153 lines
4.6 KiB
Rust
#[cfg(feature = "full")]
|
|
use diesel::Queryable;
|
|
use lemmy_db_schema::{
|
|
aggregates::structs::{CommentAggregates, CommunityAggregates, PersonAggregates},
|
|
source::{
|
|
comment::Comment,
|
|
comment_reply::CommentReply,
|
|
community::Community,
|
|
instance::Instance,
|
|
person::Person,
|
|
person_mention::PersonMention,
|
|
post::Post,
|
|
site::Site,
|
|
},
|
|
SubscribedType,
|
|
};
|
|
use serde::{Deserialize, Serialize};
|
|
use serde_with::skip_serializing_none;
|
|
#[cfg(feature = "full")]
|
|
use ts_rs::TS;
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// A community block.
|
|
pub struct CommunityBlockView {
|
|
pub person: Person,
|
|
pub community: Community,
|
|
}
|
|
|
|
#[skip_serializing_none]
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// An instance block by a user.
|
|
pub struct InstanceBlockView {
|
|
pub person: Person,
|
|
pub instance: Instance,
|
|
pub site: Option<Site>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// A community follower.
|
|
pub struct CommunityFollowerView {
|
|
pub community: Community,
|
|
pub follower: Person,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// A community moderator.
|
|
pub struct CommunityModeratorView {
|
|
pub community: Community,
|
|
pub moderator: Person,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(Queryable))]
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
/// A community person ban.
|
|
pub struct CommunityPersonBanView {
|
|
pub community: Community,
|
|
pub person: Person,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// A community view.
|
|
pub struct CommunityView {
|
|
pub community: Community,
|
|
pub subscribed: SubscribedType,
|
|
pub blocked: bool,
|
|
pub counts: CommunityAggregates,
|
|
pub banned_from_community: bool,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// A person block.
|
|
pub struct PersonBlockView {
|
|
pub person: Person,
|
|
pub target: Person,
|
|
}
|
|
|
|
#[skip_serializing_none]
|
|
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// A person mention view.
|
|
pub struct PersonMentionView {
|
|
pub person_mention: PersonMention,
|
|
pub comment: Comment,
|
|
pub creator: Person,
|
|
pub post: Post,
|
|
pub community: Community,
|
|
pub recipient: Person,
|
|
pub counts: CommentAggregates,
|
|
pub creator_banned_from_community: bool,
|
|
pub banned_from_community: bool,
|
|
pub creator_is_moderator: bool,
|
|
pub creator_is_admin: bool,
|
|
pub subscribed: SubscribedType,
|
|
pub saved: bool,
|
|
pub creator_blocked: bool,
|
|
pub my_vote: Option<i16>,
|
|
}
|
|
|
|
#[skip_serializing_none]
|
|
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// A comment reply view.
|
|
pub struct CommentReplyView {
|
|
pub comment_reply: CommentReply,
|
|
pub comment: Comment,
|
|
pub creator: Person,
|
|
pub post: Post,
|
|
pub community: Community,
|
|
pub recipient: Person,
|
|
pub counts: CommentAggregates,
|
|
pub creator_banned_from_community: bool,
|
|
pub banned_from_community: bool,
|
|
pub creator_is_moderator: bool,
|
|
pub creator_is_admin: bool,
|
|
pub subscribed: SubscribedType,
|
|
pub saved: bool,
|
|
pub creator_blocked: bool,
|
|
pub my_vote: Option<i16>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
/// A person view.
|
|
pub struct PersonView {
|
|
pub person: Person,
|
|
pub counts: PersonAggregates,
|
|
pub is_admin: bool,
|
|
}
|