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,
|
2024-04-16 23:20:44 +00:00
|
|
|
images::LocalImage,
|
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,
|
2024-03-13 16:10:58 +00:00
|
|
|
local_user_vote_display_mode::LocalUserVoteDisplayMode,
|
2023-03-01 17:19:46 +00:00
|
|
|
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-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
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,
|
2024-03-13 16:11:24 +00:00
|
|
|
pub creator_is_moderator: bool,
|
|
|
|
pub creator_is_admin: bool,
|
|
|
|
pub creator_blocked: bool,
|
|
|
|
pub subscribed: SubscribedType,
|
|
|
|
pub saved: bool,
|
2023-05-10 19:20:39 +00:00
|
|
|
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-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
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,
|
2024-03-22 22:31:08 +00:00
|
|
|
pub banned_from_community: bool,
|
2023-10-24 12:37:03 +00:00
|
|
|
pub creator_is_moderator: bool,
|
2023-11-21 16:20:24 +00:00
|
|
|
pub creator_is_admin: bool,
|
2023-05-10 19:20:39 +00:00
|
|
|
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-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
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,
|
2024-03-13 16:10:58 +00:00
|
|
|
pub local_user_vote_display_mode: LocalUserVoteDisplayMode,
|
2022-05-03 17:44:13 +00:00
|
|
|
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-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
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,
|
2024-03-13 16:11:24 +00:00
|
|
|
pub creator_is_moderator: bool,
|
|
|
|
pub creator_is_admin: bool,
|
|
|
|
pub subscribed: SubscribedType,
|
|
|
|
pub saved: bool,
|
|
|
|
pub read: bool,
|
|
|
|
pub hidden: bool,
|
|
|
|
pub creator_blocked: bool,
|
2022-05-03 17:44:13 +00:00
|
|
|
pub my_vote: Option<i16>,
|
2024-03-13 16:11:24 +00:00
|
|
|
pub unread_comments: i64,
|
2022-05-03 17:44:13 +00:00
|
|
|
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
|
2024-02-11 05:32:14 +00:00
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)]
|
2023-09-18 13:44:48 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(ts_rs::TS))]
|
2023-09-20 13:28:56 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2024-01-24 14:03:31 +00:00
|
|
|
pub struct PaginationCursor(pub String);
|
2023-09-18 13:44:48 +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-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
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,
|
2024-03-22 22:31:08 +00:00
|
|
|
pub banned_from_community: bool,
|
2023-10-24 12:37:03 +00:00
|
|
|
pub creator_is_moderator: bool,
|
2023-11-21 16:20:24 +00:00
|
|
|
pub creator_is_admin: 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,
|
2024-02-29 15:42:34 +00:00
|
|
|
pub hidden: bool,
|
2023-05-10 19:20:39 +00:00
|
|
|
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-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
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-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
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-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
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-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
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-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS, Queryable))]
|
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[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>,
|
|
|
|
}
|
2024-01-03 18:39:21 +00:00
|
|
|
|
|
|
|
#[skip_serializing_none]
|
|
|
|
#[derive(Debug, PartialEq, Eq, 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 vote view for checking a post or comments votes.
|
|
|
|
pub struct VoteView {
|
|
|
|
pub creator: Person,
|
2024-03-26 15:22:04 +00:00
|
|
|
pub creator_banned_from_community: bool,
|
2024-01-03 18:39:21 +00:00
|
|
|
pub score: i16,
|
|
|
|
}
|
2024-04-16 23:20:44 +00:00
|
|
|
|
|
|
|
#[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 local image view.
|
|
|
|
pub struct LocalImageView {
|
|
|
|
pub local_image: LocalImage,
|
|
|
|
pub person: Person,
|
|
|
|
}
|