2023-08-31 13:26:10 +00:00
|
|
|
#[cfg(feature = "full")]
|
|
|
|
use diesel::Queryable;
|
2022-05-03 17:44:13 +00:00
|
|
|
use lemmy_db_schema::{
|
|
|
|
aggregates::structs::{CommentAggregates, CommunityAggregates, PersonAggregates},
|
|
|
|
source::{
|
|
|
|
comment::Comment,
|
2022-07-30 03:55:59 +00:00
|
|
|
comment_reply::CommentReply,
|
2023-03-01 17:19:46 +00:00
|
|
|
community::Community,
|
|
|
|
person::Person,
|
2022-05-03 17:44:13 +00:00
|
|
|
person_mention::PersonMention,
|
|
|
|
post::Post,
|
|
|
|
},
|
2022-06-22 12:05:41 +00:00
|
|
|
SubscribedType,
|
2022-05-03 17:44:13 +00:00
|
|
|
};
|
|
|
|
use serde::{Deserialize, Serialize};
|
2023-04-26 04:26:10 +00:00
|
|
|
use serde_with::skip_serializing_none;
|
|
|
|
#[cfg(feature = "full")]
|
|
|
|
use ts_rs::TS;
|
2022-05-03 17:44:13 +00:00
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-08-31 13:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A community block.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct CommunityBlockView {
|
2023-03-01 17:19:46 +00:00
|
|
|
pub person: Person,
|
|
|
|
pub community: Community,
|
2022-05-03 17:44:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-08-31 13:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A community follower.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct CommunityFollowerView {
|
2023-03-01 17:19:46 +00:00
|
|
|
pub community: Community,
|
|
|
|
pub follower: Person,
|
2022-05-03 17:44:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-08-31 13:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A community moderator.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct CommunityModeratorView {
|
2023-03-01 17:19:46 +00:00
|
|
|
pub community: Community,
|
|
|
|
pub moderator: Person,
|
2022-05-03 17:44:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-08-31 13:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(Queryable))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A community person ban.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct CommunityPersonBanView {
|
2023-03-01 17:19:46 +00:00
|
|
|
pub community: Community,
|
|
|
|
pub person: Person,
|
2022-05-03 17:44:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-08-31 13:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A community view.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct CommunityView {
|
2023-03-01 17:19:46 +00:00
|
|
|
pub community: Community,
|
2022-06-22 12:05:41 +00:00
|
|
|
pub subscribed: SubscribedType,
|
2022-05-03 17:44:13 +00:00
|
|
|
pub blocked: bool,
|
|
|
|
pub counts: CommunityAggregates,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-08-31 13:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A person block.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct PersonBlockView {
|
2023-03-01 17:19:46 +00:00
|
|
|
pub person: Person,
|
|
|
|
pub target: Person,
|
2022-05-03 17:44:13 +00:00
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2023-07-26 17:07:05 +00:00
|
|
|
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
2023-08-31 13:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A person mention view.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct PersonMentionView {
|
|
|
|
pub person_mention: PersonMention,
|
|
|
|
pub comment: Comment,
|
2023-03-01 17:19:46 +00:00
|
|
|
pub creator: Person,
|
2022-05-03 17:44:13 +00:00
|
|
|
pub post: Post,
|
2023-03-01 17:19:46 +00:00
|
|
|
pub community: Community,
|
|
|
|
pub recipient: Person,
|
2022-05-03 17:44:13 +00:00
|
|
|
pub counts: CommentAggregates,
|
2023-05-10 19:20:39 +00:00
|
|
|
pub creator_banned_from_community: bool,
|
|
|
|
pub subscribed: SubscribedType,
|
|
|
|
pub saved: bool,
|
|
|
|
pub creator_blocked: bool,
|
|
|
|
pub my_vote: Option<i16>,
|
2022-05-03 17:44:13 +00:00
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2023-07-26 17:07:05 +00:00
|
|
|
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
2023-08-31 13:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A comment reply view.
|
2022-07-30 03:55:59 +00:00
|
|
|
pub struct CommentReplyView {
|
|
|
|
pub comment_reply: CommentReply,
|
|
|
|
pub comment: Comment,
|
2023-03-01 17:19:46 +00:00
|
|
|
pub creator: Person,
|
2022-07-30 03:55:59 +00:00
|
|
|
pub post: Post,
|
2023-03-01 17:19:46 +00:00
|
|
|
pub community: Community,
|
|
|
|
pub recipient: Person,
|
2022-07-30 03:55:59 +00:00
|
|
|
pub counts: CommentAggregates,
|
|
|
|
pub creator_banned_from_community: bool, // Left Join to CommunityPersonBan
|
|
|
|
pub subscribed: SubscribedType, // Left join to CommunityFollower
|
|
|
|
pub saved: bool, // Left join to CommentSaved
|
|
|
|
pub creator_blocked: bool, // Left join to PersonBlock
|
|
|
|
pub my_vote: Option<i16>, // Left join to CommentLike
|
|
|
|
}
|
|
|
|
|
2022-05-03 17:44:13 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-08-31 13:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A person view.
|
2023-03-01 17:19:46 +00:00
|
|
|
pub struct PersonView {
|
|
|
|
pub person: Person,
|
2022-05-03 17:44:13 +00:00
|
|
|
pub counts: PersonAggregates,
|
|
|
|
}
|