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, PersonAggregates, PostAggregates, SiteAggregates},
|
|
|
|
source::{
|
|
|
|
comment::Comment,
|
|
|
|
comment_report::CommentReport,
|
2023-03-01 17:19:46 +00:00
|
|
|
community::Community,
|
2023-03-20 21:32:31 +00:00
|
|
|
custom_emoji::CustomEmoji,
|
|
|
|
custom_emoji_keyword::CustomEmojiKeyword,
|
2022-10-27 09:24:07 +00:00
|
|
|
local_site::LocalSite,
|
|
|
|
local_site_rate_limit::LocalSiteRateLimit,
|
2023-03-01 17:19:46 +00:00
|
|
|
local_user::LocalUser,
|
|
|
|
person::Person,
|
2022-05-03 17:44:13 +00:00
|
|
|
post::Post,
|
|
|
|
post_report::PostReport,
|
|
|
|
private_message::PrivateMessage,
|
2022-09-19 22:58:42 +00:00
|
|
|
private_message_report::PrivateMessageReport,
|
2022-05-03 17:44:13 +00:00
|
|
|
registration_application::RegistrationApplication,
|
|
|
|
site::Site,
|
|
|
|
},
|
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
|
|
|
|
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 report view.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct CommentReportView {
|
|
|
|
pub comment_report: CommentReport,
|
|
|
|
pub comment: Comment,
|
|
|
|
pub post: Post,
|
2023-03-01 17:19:46 +00:00
|
|
|
pub community: Community,
|
|
|
|
pub creator: Person,
|
|
|
|
pub comment_creator: 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 my_vote: Option<i16>,
|
2023-03-01 17:19:46 +00:00
|
|
|
pub resolver: Option<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 comment view.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct CommentView {
|
|
|
|
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,
|
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
|
|
|
}
|
|
|
|
|
|
|
|
#[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 local user view.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct LocalUserView {
|
|
|
|
pub local_user: LocalUser,
|
|
|
|
pub person: Person,
|
|
|
|
pub counts: PersonAggregates,
|
|
|
|
}
|
|
|
|
|
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 post report view.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct PostReportView {
|
|
|
|
pub post_report: PostReport,
|
|
|
|
pub post: Post,
|
2023-03-01 17:19:46 +00:00
|
|
|
pub community: Community,
|
|
|
|
pub creator: Person,
|
|
|
|
pub post_creator: Person,
|
2022-05-03 17:44:13 +00:00
|
|
|
pub creator_banned_from_community: bool,
|
|
|
|
pub my_vote: Option<i16>,
|
|
|
|
pub counts: PostAggregates,
|
2023-03-01 17:19:46 +00:00
|
|
|
pub resolver: Option<Person>,
|
2022-05-03 17:44:13 +00:00
|
|
|
}
|
|
|
|
|
2023-09-18 13:44:48 +00:00
|
|
|
/// currently this is just a wrapper around post id, but should be seen as opaque from the client's perspective
|
|
|
|
/// stringified since we might want to use arbitrary info later, with a P prepended to prevent ossification
|
|
|
|
/// (api users love to make assumptions (e.g. parse stuff that looks like numbers as numbers) about apis that aren't part of the spec
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
|
|
#[cfg_attr(feature = "full", derive(ts_rs::TS))]
|
|
|
|
pub struct PaginationCursor(pub(crate) String);
|
|
|
|
|
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 post view.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct PostView {
|
|
|
|
pub post: Post,
|
2023-03-01 17:19:46 +00:00
|
|
|
pub creator: Person,
|
|
|
|
pub community: Community,
|
2023-05-10 19:20:39 +00:00
|
|
|
pub creator_banned_from_community: bool,
|
2022-05-03 17:44:13 +00:00
|
|
|
pub counts: PostAggregates,
|
2023-05-10 19:20:39 +00:00
|
|
|
pub subscribed: SubscribedType,
|
|
|
|
pub saved: bool,
|
|
|
|
pub read: bool,
|
|
|
|
pub creator_blocked: bool,
|
|
|
|
pub my_vote: Option<i16>,
|
|
|
|
pub unread_comments: i64,
|
2022-05-03 17:44:13 +00:00
|
|
|
}
|
|
|
|
|
2022-09-26 14:09:32 +00:00
|
|
|
#[derive(Debug, PartialEq, Eq, 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 private message view.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct PrivateMessageView {
|
|
|
|
pub private_message: PrivateMessage,
|
2023-03-01 17:19:46 +00:00
|
|
|
pub creator: Person,
|
|
|
|
pub recipient: Person,
|
2022-05-03 17:44:13 +00:00
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2022-09-26 14:09:32 +00:00
|
|
|
#[derive(Debug, PartialEq, Eq, 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 private message report view.
|
2022-09-19 22:58:42 +00:00
|
|
|
pub struct PrivateMessageReportView {
|
|
|
|
pub private_message_report: PrivateMessageReport,
|
|
|
|
pub private_message: PrivateMessage,
|
2023-03-01 17:19:46 +00:00
|
|
|
pub private_message_creator: Person,
|
|
|
|
pub creator: Person,
|
|
|
|
pub resolver: Option<Person>,
|
2022-09-19 22:58:42 +00:00
|
|
|
}
|
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2022-09-26 14:09:32 +00:00
|
|
|
#[derive(Debug, PartialEq, Eq, 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 registration application view.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct RegistrationApplicationView {
|
|
|
|
pub registration_application: RegistrationApplication,
|
2023-03-01 17:19:46 +00:00
|
|
|
pub creator_local_user: LocalUser,
|
|
|
|
pub creator: Person,
|
|
|
|
pub admin: Option<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 site view.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct SiteView {
|
|
|
|
pub site: Site,
|
2022-10-27 09:24:07 +00:00
|
|
|
pub local_site: LocalSite,
|
|
|
|
pub local_site_rate_limit: LocalSiteRateLimit,
|
2022-05-03 17:44:13 +00:00
|
|
|
pub counts: SiteAggregates,
|
|
|
|
}
|
2023-04-26 04:26:10 +00:00
|
|
|
|
2023-03-20 21:32:31 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A custom emoji view.
|
2023-03-20 21:32:31 +00:00
|
|
|
pub struct CustomEmojiView {
|
|
|
|
pub custom_emoji: CustomEmoji,
|
|
|
|
pub keywords: Vec<CustomEmojiKeyword>,
|
|
|
|
}
|