2022-05-03 17:44:13 +00:00
|
|
|
use crate::sensitive::Sensitive;
|
2022-09-19 22:58:42 +00:00
|
|
|
use lemmy_db_schema::{
|
|
|
|
newtypes::{CommentReplyId, CommunityId, LanguageId, PersonId, PersonMentionId},
|
|
|
|
CommentSortType,
|
|
|
|
SortType,
|
|
|
|
};
|
|
|
|
use lemmy_db_views::structs::{CommentView, PostView};
|
2022-07-30 03:55:59 +00:00
|
|
|
use lemmy_db_views_actor::structs::{
|
|
|
|
CommentReplyView,
|
|
|
|
CommunityModeratorView,
|
|
|
|
PersonMentionView,
|
2023-03-01 17:19:46 +00:00
|
|
|
PersonView,
|
2022-07-30 03:55:59 +00:00
|
|
|
};
|
2020-09-01 14:25:34 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct Login {
|
2021-12-06 14:54:47 +00:00
|
|
|
pub username_or_email: Sensitive<String>,
|
|
|
|
pub password: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct Register {
|
|
|
|
pub username: String,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub password: Sensitive<String>,
|
|
|
|
pub password_verify: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub show_nsfw: bool,
|
2021-12-15 19:49:59 +00:00
|
|
|
/// email is mandatory if email verification is enabled on the server
|
2021-12-06 14:54:47 +00:00
|
|
|
pub email: Option<Sensitive<String>>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub captcha_uuid: Option<String>,
|
|
|
|
pub captcha_answer: Option<String>,
|
2021-10-01 11:37:39 +00:00
|
|
|
pub honeypot: Option<String>,
|
2021-12-15 19:49:59 +00:00
|
|
|
/// An answer is mandatory if require application is enabled on the server
|
|
|
|
pub answer: Option<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetCaptcha {}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetCaptchaResponse {
|
2021-01-18 21:57:31 +00:00
|
|
|
pub ok: Option<CaptchaResponse>, // Will be None if captchas are disabled
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct CaptchaResponse {
|
2021-04-01 17:30:24 +00:00
|
|
|
pub png: String, // A Base64 encoded png
|
|
|
|
pub wav: String, // A Base64 encoded wav audio
|
2020-09-01 14:25:34 +00:00
|
|
|
pub uuid: String,
|
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct SaveUserSettings {
|
2021-03-11 04:43:11 +00:00
|
|
|
pub show_nsfw: Option<bool>,
|
2021-03-31 10:54:46 +00:00
|
|
|
pub show_scores: Option<bool>,
|
2021-03-11 04:43:11 +00:00
|
|
|
pub theme: Option<String>,
|
|
|
|
pub default_sort_type: Option<i16>,
|
|
|
|
pub default_listing_type: Option<i16>,
|
2022-08-18 19:11:19 +00:00
|
|
|
pub interface_language: Option<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub avatar: Option<String>,
|
|
|
|
pub banner: Option<String>,
|
2021-04-01 17:57:45 +00:00
|
|
|
pub display_name: Option<String>,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub email: Option<Sensitive<String>>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub bio: Option<String>,
|
|
|
|
pub matrix_user_id: Option<String>,
|
2021-03-11 04:43:11 +00:00
|
|
|
pub show_avatars: Option<bool>,
|
|
|
|
pub send_notifications_to_email: Option<bool>,
|
2021-04-21 21:41:14 +00:00
|
|
|
pub bot_account: Option<bool>,
|
|
|
|
pub show_bot_accounts: Option<bool>,
|
2021-04-24 22:26:50 +00:00
|
|
|
pub show_read_posts: Option<bool>,
|
2021-07-22 20:07:40 +00:00
|
|
|
pub show_new_post_notifs: Option<bool>,
|
2022-08-18 19:11:19 +00:00
|
|
|
pub discussion_languages: Option<Vec<LanguageId>>,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2021-04-01 21:39:01 +00:00
|
|
|
pub struct ChangePassword {
|
2021-12-06 14:54:47 +00:00
|
|
|
pub new_password: Sensitive<String>,
|
|
|
|
pub new_password_verify: Sensitive<String>,
|
|
|
|
pub old_password: Sensitive<String>,
|
|
|
|
pub auth: Sensitive<String>,
|
2021-04-01 21:39:01 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct LoginResponse {
|
2021-12-15 19:49:59 +00:00
|
|
|
/// This is None in response to `Register` if email verification is enabled, or the server requires registration applications.
|
|
|
|
pub jwt: Option<Sensitive<String>>,
|
|
|
|
pub registration_created: bool,
|
|
|
|
pub verify_email_sent: bool,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2021-03-10 22:33:55 +00:00
|
|
|
pub struct GetPersonDetails {
|
2021-04-15 03:37:51 +00:00
|
|
|
pub person_id: Option<PersonId>, // One of these two are required
|
2021-07-20 04:29:50 +00:00
|
|
|
/// Example: dessalines , or dessalines@xyz.tld
|
2020-09-01 14:25:34 +00:00
|
|
|
pub username: Option<String>,
|
2022-05-06 20:55:07 +00:00
|
|
|
pub sort: Option<SortType>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community_id: Option<CommunityId>,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub saved_only: Option<bool>,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Option<Sensitive<String>>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2021-03-10 22:33:55 +00:00
|
|
|
pub struct GetPersonDetailsResponse {
|
2023-03-01 17:19:46 +00:00
|
|
|
pub person_view: PersonView,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub comments: Vec<CommentView>,
|
|
|
|
pub posts: Vec<PostView>,
|
2021-08-19 20:54:15 +00:00
|
|
|
pub moderates: Vec<CommunityModeratorView>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetRepliesResponse {
|
2022-07-30 03:55:59 +00:00
|
|
|
pub replies: Vec<CommentReplyView>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2021-03-10 22:33:55 +00:00
|
|
|
pub struct GetPersonMentionsResponse {
|
|
|
|
pub mentions: Vec<PersonMentionView>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct MarkAllAsRead {
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct AddAdmin {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub person_id: PersonId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub added: bool,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct AddAdminResponse {
|
2023-03-01 17:19:46 +00:00
|
|
|
pub admins: Vec<PersonView>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2021-03-10 22:33:55 +00:00
|
|
|
pub struct BanPerson {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub person_id: PersonId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub ban: bool,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub remove_data: Option<bool>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub reason: Option<String>,
|
|
|
|
pub expires: Option<i64>,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2021-11-19 20:56:41 +00:00
|
|
|
pub struct GetBannedPersons {
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2021-11-19 20:56:41 +00:00
|
|
|
pub struct BannedPersonsResponse {
|
2023-03-01 17:19:46 +00:00
|
|
|
pub banned: Vec<PersonView>,
|
2021-11-19 20:56:41 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2021-03-10 22:33:55 +00:00
|
|
|
pub struct BanPersonResponse {
|
2023-03-01 17:19:46 +00:00
|
|
|
pub person_view: PersonView,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub banned: bool,
|
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2021-08-19 20:54:15 +00:00
|
|
|
pub struct BlockPerson {
|
|
|
|
pub person_id: PersonId,
|
|
|
|
pub block: bool,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2021-08-19 20:54:15 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2021-08-19 20:54:15 +00:00
|
|
|
pub struct BlockPersonResponse {
|
2023-03-01 17:19:46 +00:00
|
|
|
pub person_view: PersonView,
|
2021-08-19 20:54:15 +00:00
|
|
|
pub blocked: bool,
|
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetReplies {
|
2022-07-30 03:55:59 +00:00
|
|
|
pub sort: Option<CommentSortType>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub unread_only: Option<bool>,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2021-03-10 22:33:55 +00:00
|
|
|
pub struct GetPersonMentions {
|
2022-07-30 03:55:59 +00:00
|
|
|
pub sort: Option<CommentSortType>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
2021-04-15 03:37:51 +00:00
|
|
|
pub unread_only: Option<bool>,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2021-03-10 22:33:55 +00:00
|
|
|
pub struct MarkPersonMentionAsRead {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub person_mention_id: PersonMentionId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub read: bool,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2021-03-10 22:33:55 +00:00
|
|
|
pub struct PersonMentionResponse {
|
|
|
|
pub person_mention_view: PersonMentionView,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-07-30 03:55:59 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
|
|
|
pub struct MarkCommentReplyAsRead {
|
|
|
|
pub comment_reply_id: CommentReplyId,
|
|
|
|
pub read: bool,
|
|
|
|
pub auth: Sensitive<String>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
|
|
pub struct CommentReplyResponse {
|
|
|
|
pub comment_reply_view: CommentReplyView,
|
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct DeleteAccount {
|
2021-12-06 14:54:47 +00:00
|
|
|
pub password: Sensitive<String>,
|
|
|
|
pub auth: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2021-12-15 19:49:59 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
|
|
pub struct DeleteAccountResponse {}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct PasswordReset {
|
2021-12-06 14:54:47 +00:00
|
|
|
pub email: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct PasswordResetResponse {}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2022-04-13 18:12:25 +00:00
|
|
|
pub struct PasswordChangeAfterReset {
|
2021-12-06 14:54:47 +00:00
|
|
|
pub token: Sensitive<String>,
|
|
|
|
pub password: Sensitive<String>,
|
|
|
|
pub password_verify: Sensitive<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2020-10-25 02:59:13 +00:00
|
|
|
pub struct GetReportCount {
|
2021-09-28 10:36:17 +00:00
|
|
|
pub community_id: Option<CommunityId>,
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2020-10-25 02:59:13 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2020-10-25 02:59:13 +00:00
|
|
|
pub struct GetReportCountResponse {
|
2021-09-28 10:36:17 +00:00
|
|
|
pub community_id: Option<CommunityId>,
|
2020-11-04 02:15:11 +00:00
|
|
|
pub comment_reports: i64,
|
|
|
|
pub post_reports: i64,
|
2022-09-19 22:58:42 +00:00
|
|
|
pub private_message_reports: Option<i64>,
|
2020-10-25 02:59:13 +00:00
|
|
|
}
|
2021-10-16 10:43:41 +00:00
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
2021-10-16 10:43:41 +00:00
|
|
|
pub struct GetUnreadCount {
|
2021-12-06 14:54:47 +00:00
|
|
|
pub auth: Sensitive<String>,
|
2021-10-16 10:43:41 +00:00
|
|
|
}
|
|
|
|
|
2021-12-06 14:54:47 +00:00
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
2021-10-16 10:43:41 +00:00
|
|
|
pub struct GetUnreadCountResponse {
|
|
|
|
pub replies: i64,
|
|
|
|
pub mentions: i64,
|
|
|
|
pub private_messages: i64,
|
|
|
|
}
|
2021-12-15 19:49:59 +00:00
|
|
|
|
2022-11-28 14:29:33 +00:00
|
|
|
#[derive(Serialize, Deserialize, Clone, Default, Debug)]
|
2021-12-15 19:49:59 +00:00
|
|
|
pub struct VerifyEmail {
|
|
|
|
pub token: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
|
|
pub struct VerifyEmailResponse {}
|