lemmy/crates/db_views_actor/src/structs.rs
Dessalines c9f1407429
Diesel 2.0.0 upgrade (#2452)
* Initial commit to bump diesel to 2.0.0-rc.0 and see what happens

* Add chrono feature from diesel

* db_schema crate is close to building?

* Upgrade diesel-derive-newtype

* Mostly modifying references to connections to be mutable ones; also used
new way to do migrations as suggested by the migration guide; a lot more
compiles now, though I can't figure out this tricky ToSql issue at the
moment

* Running clippy --fix

* Trying to fix drone clippy 1

* Fix clippy

* Upgrade clux-musl

* Trying to fix drone clippy 2

* Trying to fix drone clippy 3

* Trying to fix drone clippy 5

* Adding diesel table aliases, removing sql view hack. Fixes #2101

Co-authored-by: Steven Chu <stevenc1@gmail.com>
Co-authored-by: Nutomic <me@nutomic.com>
2022-09-26 14:09:32 +00:00

90 lines
2.7 KiB
Rust

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