2020-12-21 16:30:34 +00:00
|
|
|
use lemmy_db_views::{
|
2020-12-16 22:16:48 +00:00
|
|
|
comment_view::CommentView,
|
|
|
|
post_view::PostView,
|
|
|
|
private_message_view::PrivateMessageView,
|
2020-12-21 23:27:42 +00:00
|
|
|
};
|
|
|
|
use lemmy_db_views_actor::{
|
|
|
|
community_follower_view::CommunityFollowerView,
|
|
|
|
community_moderator_view::CommunityModeratorView,
|
2021-03-10 22:33:55 +00:00
|
|
|
person_mention_view::PersonMentionView,
|
|
|
|
person_view::PersonViewSafe,
|
2020-09-01 14:25:34 +00:00
|
|
|
};
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize, Debug)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct Login {
|
|
|
|
pub username_or_email: String,
|
|
|
|
pub password: String,
|
|
|
|
}
|
2021-03-18 20:25:21 +00:00
|
|
|
use lemmy_db_schema::{CommunityId, PersonId, PersonMentionId, PrivateMessageId};
|
2020-09-01 14:25:34 +00:00
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct Register {
|
|
|
|
pub username: String,
|
|
|
|
pub email: Option<String>,
|
|
|
|
pub password: String,
|
|
|
|
pub password_verify: String,
|
|
|
|
pub show_nsfw: bool,
|
|
|
|
pub captcha_uuid: Option<String>,
|
|
|
|
pub captcha_answer: Option<String>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetCaptcha {}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize)]
|
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
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize)]
|
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,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct SaveUserSettings {
|
2021-03-11 04:43:11 +00:00
|
|
|
pub show_nsfw: Option<bool>,
|
|
|
|
pub theme: Option<String>,
|
|
|
|
pub default_sort_type: Option<i16>,
|
|
|
|
pub default_listing_type: Option<i16>,
|
|
|
|
pub lang: Option<String>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub avatar: Option<String>,
|
|
|
|
pub banner: Option<String>,
|
|
|
|
pub preferred_username: Option<String>,
|
|
|
|
pub email: Option<String>,
|
|
|
|
pub bio: Option<String>,
|
|
|
|
pub matrix_user_id: Option<String>,
|
|
|
|
pub new_password: Option<String>,
|
|
|
|
pub new_password_verify: Option<String>,
|
|
|
|
pub old_password: Option<String>,
|
2021-03-11 04:43:11 +00:00
|
|
|
pub show_avatars: Option<bool>,
|
|
|
|
pub send_notifications_to_email: Option<bool>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct LoginResponse {
|
|
|
|
pub jwt: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2021-03-10 22:33:55 +00:00
|
|
|
pub struct GetPersonDetails {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub person_id: Option<PersonId>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub username: Option<String>,
|
|
|
|
pub sort: String,
|
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community_id: Option<CommunityId>,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub saved_only: bool,
|
|
|
|
pub auth: Option<String>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize)]
|
2021-03-10 22:33:55 +00:00
|
|
|
pub struct GetPersonDetailsResponse {
|
|
|
|
pub person_view: PersonViewSafe,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub follows: Vec<CommunityFollowerView>,
|
|
|
|
pub moderates: Vec<CommunityModeratorView>,
|
|
|
|
pub comments: Vec<CommentView>,
|
|
|
|
pub posts: Vec<PostView>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetRepliesResponse {
|
2020-12-15 19:39:18 +00:00
|
|
|
pub replies: Vec<CommentView>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize)]
|
2021-03-10 22:33:55 +00:00
|
|
|
pub struct GetPersonMentionsResponse {
|
|
|
|
pub mentions: Vec<PersonMentionView>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct MarkAllAsRead {
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
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,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct AddAdminResponse {
|
2021-03-10 22:33:55 +00:00
|
|
|
pub admins: Vec<PersonViewSafe>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
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,
|
2020-12-20 01:10:47 +00:00
|
|
|
pub remove_data: bool,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub reason: Option<String>,
|
|
|
|
pub expires: Option<i64>,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize, Clone)]
|
2021-03-10 22:33:55 +00:00
|
|
|
pub struct BanPersonResponse {
|
|
|
|
pub person_view: PersonViewSafe,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub banned: bool,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetReplies {
|
|
|
|
pub sort: String,
|
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
|
|
|
pub unread_only: bool,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2021-03-10 22:33:55 +00:00
|
|
|
pub struct GetPersonMentions {
|
2020-09-01 14:25:34 +00:00
|
|
|
pub sort: String,
|
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
|
|
|
pub unread_only: bool,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
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,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize, 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
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct DeleteAccount {
|
|
|
|
pub password: String,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct PasswordReset {
|
|
|
|
pub email: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct PasswordResetResponse {}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct PasswordChange {
|
|
|
|
pub token: String,
|
|
|
|
pub password: String,
|
|
|
|
pub password_verify: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct CreatePrivateMessage {
|
|
|
|
pub content: String,
|
2021-03-18 20:25:21 +00:00
|
|
|
pub recipient_id: PersonId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct EditPrivateMessage {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub private_message_id: PrivateMessageId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub content: String,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct DeletePrivateMessage {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub private_message_id: PrivateMessageId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub deleted: bool,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct MarkPrivateMessageAsRead {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub private_message_id: PrivateMessageId,
|
2020-09-01 14:25:34 +00:00
|
|
|
pub read: bool,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetPrivateMessages {
|
|
|
|
pub unread_only: bool,
|
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct PrivateMessagesResponse {
|
2020-12-20 01:10:47 +00:00
|
|
|
pub private_messages: Vec<PrivateMessageView>,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct PrivateMessageResponse {
|
2020-12-20 01:10:47 +00:00
|
|
|
pub private_message_view: PrivateMessageView,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2020-10-25 02:59:13 +00:00
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct GetReportCount {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community: Option<CommunityId>,
|
2020-10-25 02:59:13 +00:00
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
|
|
|
pub struct GetReportCountResponse {
|
2021-03-18 20:25:21 +00:00
|
|
|
pub community: Option<CommunityId>,
|
2020-11-04 02:15:11 +00:00
|
|
|
pub comment_reports: i64,
|
|
|
|
pub post_reports: i64,
|
2020-10-25 02:59:13 +00:00
|
|
|
}
|