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::{
|
2024-11-04 13:48:29 +00:00
|
|
|
aggregates::structs::{CommentAggregates, CommunityAggregates, PersonAggregates, PostAggregates},
|
2022-05-03 17:44:13 +00:00
|
|
|
source::{
|
|
|
|
comment::Comment,
|
2022-07-30 03:55:59 +00:00
|
|
|
comment_reply::CommentReply,
|
2023-03-01 17:19:46 +00:00
|
|
|
community::Community,
|
2024-12-11 20:06:08 +00:00
|
|
|
images::ImageDetails,
|
2023-03-01 17:19:46 +00:00
|
|
|
person::Person,
|
2024-11-02 17:04:31 +00:00
|
|
|
person_comment_mention::PersonCommentMention,
|
2024-11-04 13:48:29 +00:00
|
|
|
person_post_mention::PersonPostMention,
|
2022-05-03 17:44:13 +00:00
|
|
|
post::Post,
|
2024-12-11 20:06:08 +00:00
|
|
|
private_message::PrivateMessage,
|
2022-05-03 17:44:13 +00:00
|
|
|
},
|
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-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 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-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 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-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
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-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 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,
|
2024-02-18 14:09:46 +00:00
|
|
|
pub banned_from_community: bool,
|
2022-05-03 17:44:13 +00:00
|
|
|
}
|
|
|
|
|
2024-10-15 21:15:43 +00:00
|
|
|
/// The community sort types. See here for descriptions: https://join-lemmy.org/docs/en/users/03-votes-and-ranking.html
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, Hash)]
|
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
|
|
pub enum CommunitySortType {
|
|
|
|
#[default]
|
|
|
|
Active,
|
|
|
|
Hot,
|
|
|
|
New,
|
|
|
|
Old,
|
|
|
|
TopDay,
|
|
|
|
TopWeek,
|
|
|
|
TopMonth,
|
|
|
|
TopYear,
|
|
|
|
TopAll,
|
|
|
|
MostComments,
|
|
|
|
NewComments,
|
|
|
|
TopHour,
|
|
|
|
TopSixHour,
|
|
|
|
TopTwelveHour,
|
|
|
|
TopThreeMonths,
|
|
|
|
TopSixMonths,
|
|
|
|
TopNineMonths,
|
|
|
|
Controversial,
|
|
|
|
Scaled,
|
|
|
|
NameAsc,
|
|
|
|
NameDesc,
|
|
|
|
}
|
|
|
|
|
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))]
|
2024-11-04 13:48:29 +00:00
|
|
|
/// A person comment mention view.
|
2024-11-02 17:04:31 +00:00
|
|
|
pub struct PersonCommentMentionView {
|
|
|
|
pub person_comment_mention: PersonCommentMention,
|
2022-05-03 17:44:13 +00:00
|
|
|
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,
|
2024-03-26 16:06:11 +00:00
|
|
|
pub banned_from_community: bool,
|
2023-11-03 13:41:00 +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,
|
2024-11-06 14:50:13 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(optional))]
|
2023-05-10 19:20:39 +00:00
|
|
|
pub my_vote: Option<i16>,
|
2022-05-03 17:44:13 +00:00
|
|
|
}
|
|
|
|
|
2024-11-04 13:48:29 +00:00
|
|
|
#[skip_serializing_none]
|
|
|
|
#[derive(Debug, PartialEq, 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 person post mention view.
|
|
|
|
pub struct PersonPostMentionView {
|
|
|
|
pub person_post_mention: PersonPostMention,
|
|
|
|
pub post: Post,
|
|
|
|
pub creator: Person,
|
|
|
|
pub community: Community,
|
2024-12-11 20:06:08 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(optional))]
|
|
|
|
pub image_details: Option<ImageDetails>,
|
2024-11-04 13:48:29 +00:00
|
|
|
pub recipient: Person,
|
|
|
|
pub counts: PostAggregates,
|
|
|
|
pub creator_banned_from_community: bool,
|
|
|
|
pub banned_from_community: bool,
|
|
|
|
pub creator_is_moderator: bool,
|
|
|
|
pub creator_is_admin: bool,
|
|
|
|
pub subscribed: SubscribedType,
|
|
|
|
pub saved: bool,
|
2024-12-11 20:06:08 +00:00
|
|
|
pub read: bool,
|
|
|
|
pub hidden: bool,
|
2024-11-04 13:48:29 +00:00
|
|
|
pub creator_blocked: bool,
|
2024-12-11 20:06:08 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(optional))]
|
2024-11-04 13:48:29 +00:00
|
|
|
pub my_vote: Option<i16>,
|
2024-12-11 20:06:08 +00:00
|
|
|
pub unread_comments: i64,
|
2024-11-04 13:48:29 +00:00
|
|
|
}
|
2024-11-02 17:04:31 +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 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,
|
2023-11-03 13:41:00 +00:00
|
|
|
pub creator_banned_from_community: bool,
|
2024-03-26 16:06:11 +00:00
|
|
|
pub banned_from_community: bool,
|
2023-11-03 13:41:00 +00:00
|
|
|
pub creator_is_moderator: bool,
|
2023-11-21 16:20:24 +00:00
|
|
|
pub creator_is_admin: bool,
|
2023-11-03 13:41:00 +00:00
|
|
|
pub subscribed: SubscribedType,
|
|
|
|
pub saved: bool,
|
|
|
|
pub creator_blocked: bool,
|
2024-11-06 14:50:13 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(optional))]
|
2023-11-03 13:41:00 +00:00
|
|
|
pub my_vote: Option<i16>,
|
2022-07-30 03:55:59 +00:00
|
|
|
}
|
|
|
|
|
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 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,
|
2023-11-21 16:20:24 +00:00
|
|
|
pub is_admin: bool,
|
2022-05-03 17:44:13 +00:00
|
|
|
}
|
2024-11-07 10:49:05 +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))]
|
|
|
|
pub struct PendingFollow {
|
|
|
|
pub person: Person,
|
|
|
|
pub community: Community,
|
|
|
|
pub is_new_instance: bool,
|
|
|
|
pub subscribed: SubscribedType,
|
|
|
|
}
|
2024-12-11 20:06:08 +00:00
|
|
|
|
|
|
|
#[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 private message view.
|
|
|
|
pub struct PrivateMessageView {
|
|
|
|
pub private_message: PrivateMessage,
|
|
|
|
pub creator: Person,
|
|
|
|
pub recipient: Person,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// like PaginationCursor but for the report_combined table
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)]
|
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
|
|
pub struct InboxCombinedPaginationCursor(pub String);
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
|
|
#[cfg_attr(feature = "full", derive(Queryable))]
|
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
|
|
|
/// A combined inbox view
|
|
|
|
pub struct InboxCombinedViewInternal {
|
|
|
|
// Comment reply
|
|
|
|
pub comment_reply: Option<CommentReply>,
|
|
|
|
// Person comment mention
|
|
|
|
pub person_comment_mention: Option<PersonCommentMention>,
|
|
|
|
// Person post mention
|
|
|
|
pub person_post_mention: Option<PersonPostMention>,
|
|
|
|
pub post_counts: Option<PostAggregates>,
|
|
|
|
pub post_unread_comments: Option<i64>,
|
|
|
|
pub post_saved: bool,
|
|
|
|
pub post_read: bool,
|
|
|
|
pub post_hidden: bool,
|
|
|
|
pub my_post_vote: Option<i16>,
|
|
|
|
pub image_details: Option<ImageDetails>,
|
|
|
|
// Private message
|
|
|
|
pub private_message: Option<PrivateMessage>,
|
|
|
|
// Shared
|
|
|
|
pub post: Option<Post>,
|
|
|
|
pub community: Option<Community>,
|
|
|
|
pub comment: Option<Comment>,
|
|
|
|
pub comment_counts: Option<CommentAggregates>,
|
|
|
|
pub comment_saved: bool,
|
|
|
|
pub my_comment_vote: Option<i16>,
|
|
|
|
pub subscribed: SubscribedType,
|
|
|
|
pub item_creator: Person,
|
|
|
|
pub item_recipient: Person,
|
|
|
|
pub item_creator_is_admin: bool,
|
|
|
|
pub item_creator_is_moderator: bool,
|
|
|
|
pub item_creator_banned_from_community: bool,
|
|
|
|
pub item_creator_blocked: bool,
|
|
|
|
pub banned_from_community: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
|
|
// Use serde's internal tagging, to work easier with javascript libraries
|
|
|
|
#[serde(tag = "type_")]
|
|
|
|
pub enum InboxCombinedView {
|
|
|
|
CommentReply(CommentReplyView),
|
|
|
|
CommentMention(PersonCommentMentionView),
|
|
|
|
PostMention(PersonPostMentionView),
|
|
|
|
PrivateMessage(PrivateMessageView),
|
|
|
|
}
|