lemmy/crates/db_views_actor/src/structs.rs
Dessalines 985fe24669
Get rid of Safe Views, use serde_skip (#2767)
* Get rid of Safe Views, use serde_skip

- Also change the ViewToVec, to work with non-vector cases. Might be
  necessary in preparation for #2763
- Fixes #2712

* Forgot one safe

---------

Co-authored-by: Nutomic <me@nutomic.com>
2023-03-01 18:19:46 +01:00

89 lines
2.6 KiB
Rust

use lemmy_db_schema::{
aggregates::structs::{CommentAggregates, CommunityAggregates, PersonAggregates},
source::{
comment::Comment,
comment_reply::CommentReply,
community::Community,
person::Person,
person_mention::PersonMention,
post::Post,
},
SubscribedType,
};
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct CommunityBlockView {
pub person: Person,
pub community: Community,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct CommunityFollowerView {
pub community: Community,
pub follower: Person,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct CommunityModeratorView {
pub community: Community,
pub moderator: Person,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct CommunityPersonBanView {
pub community: Community,
pub person: Person,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct CommunityView {
pub community: Community,
pub subscribed: SubscribedType,
pub blocked: bool,
pub counts: CommunityAggregates,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct PersonBlockView {
pub person: Person,
pub target: Person,
}
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
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, // 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
}
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
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, // 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
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct PersonView {
pub person: Person,
pub counts: PersonAggregates,
}