lemmy/crates/api_common/src/person.rs

254 lines
5.5 KiB
Rust
Raw Normal View History

use lemmy_db_views::{
2020-12-16 22:16:48 +00:00
comment_view::CommentView,
post_view::PostView,
private_message_view::PrivateMessageView,
};
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,
};
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Debug)]
pub struct Login {
pub username_or_email: String,
pub password: String,
}
use lemmy_db_schema::{CommunityId, DbLanguage, PersonId, PersonMentionId, PrivateMessageId};
#[derive(Deserialize)]
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>,
pub discussion_languages: Vec<DbLanguage>,
}
#[derive(Deserialize)]
pub struct GetCaptcha {}
#[derive(Serialize)]
pub struct GetCaptchaResponse {
pub ok: Option<CaptchaResponse>, // Will be None if captchas are disabled
}
#[derive(Serialize)]
pub struct CaptchaResponse {
pub png: String, // A Base64 encoded png
pub wav: String, // A Base64 encoded wav audio
pub uuid: String,
}
#[derive(Deserialize)]
pub struct SaveUserSettings {
2021-03-11 04:43:11 +00:00
pub show_nsfw: Option<bool>,
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>,
pub interface_language: Option<String>,
pub avatar: Option<String>,
pub banner: Option<String>,
pub display_name: Option<String>,
pub email: Option<String>,
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>,
pub auth: String,
pub discussion_languages: Option<Vec<DbLanguage>>,
}
#[derive(Deserialize)]
pub struct ChangePassword {
pub new_password: String,
pub new_password_verify: String,
pub old_password: String,
pub auth: String,
}
#[derive(Serialize)]
pub struct LoginResponse {
pub jwt: String,
}
#[derive(Deserialize)]
2021-03-10 22:33:55 +00:00
pub struct GetPersonDetails {
pub person_id: Option<PersonId>,
pub username: Option<String>,
pub sort: String,
pub page: Option<i64>,
pub limit: Option<i64>,
pub community_id: Option<CommunityId>,
pub saved_only: bool,
pub auth: Option<String>,
}
#[derive(Serialize)]
2021-03-10 22:33:55 +00:00
pub struct GetPersonDetailsResponse {
pub person_view: PersonViewSafe,
pub follows: Vec<CommunityFollowerView>,
pub moderates: Vec<CommunityModeratorView>,
pub comments: Vec<CommentView>,
pub posts: Vec<PostView>,
}
#[derive(Serialize)]
pub struct GetRepliesResponse {
2020-12-15 19:39:18 +00:00
pub replies: Vec<CommentView>,
}
#[derive(Serialize)]
2021-03-10 22:33:55 +00:00
pub struct GetPersonMentionsResponse {
pub mentions: Vec<PersonMentionView>,
}
#[derive(Deserialize)]
pub struct MarkAllAsRead {
pub auth: String,
}
#[derive(Deserialize)]
pub struct AddAdmin {
pub person_id: PersonId,
pub added: bool,
pub auth: String,
}
#[derive(Serialize, Clone)]
pub struct AddAdminResponse {
2021-03-10 22:33:55 +00:00
pub admins: Vec<PersonViewSafe>,
}
#[derive(Deserialize)]
2021-03-10 22:33:55 +00:00
pub struct BanPerson {
pub person_id: PersonId,
pub ban: bool,
pub remove_data: bool,
pub reason: Option<String>,
pub expires: Option<i64>,
pub auth: String,
}
#[derive(Serialize, Clone)]
2021-03-10 22:33:55 +00:00
pub struct BanPersonResponse {
pub person_view: PersonViewSafe,
pub banned: bool,
}
#[derive(Deserialize)]
pub struct GetReplies {
pub sort: String,
pub page: Option<i64>,
pub limit: Option<i64>,
pub unread_only: bool,
pub auth: String,
}
#[derive(Deserialize)]
2021-03-10 22:33:55 +00:00
pub struct GetPersonMentions {
pub sort: String,
pub page: Option<i64>,
pub limit: Option<i64>,
pub unread_only: bool,
pub auth: String,
}
#[derive(Deserialize)]
2021-03-10 22:33:55 +00:00
pub struct MarkPersonMentionAsRead {
pub person_mention_id: PersonMentionId,
pub read: bool,
pub auth: String,
}
#[derive(Serialize, Clone)]
2021-03-10 22:33:55 +00:00
pub struct PersonMentionResponse {
pub person_mention_view: PersonMentionView,
}
#[derive(Deserialize)]
pub struct DeleteAccount {
pub password: String,
pub auth: String,
}
#[derive(Deserialize)]
pub struct PasswordReset {
pub email: String,
}
#[derive(Serialize, Clone)]
pub struct PasswordResetResponse {}
#[derive(Deserialize)]
pub struct PasswordChange {
pub token: String,
pub password: String,
pub password_verify: String,
}
#[derive(Deserialize)]
pub struct CreatePrivateMessage {
pub content: String,
pub recipient_id: PersonId,
pub auth: String,
}
#[derive(Deserialize)]
pub struct EditPrivateMessage {
pub private_message_id: PrivateMessageId,
pub content: String,
pub auth: String,
}
#[derive(Deserialize)]
pub struct DeletePrivateMessage {
pub private_message_id: PrivateMessageId,
pub deleted: bool,
pub auth: String,
}
#[derive(Deserialize)]
pub struct MarkPrivateMessageAsRead {
pub private_message_id: PrivateMessageId,
pub read: bool,
pub auth: String,
}
#[derive(Deserialize)]
pub struct GetPrivateMessages {
pub unread_only: bool,
pub page: Option<i64>,
pub limit: Option<i64>,
pub auth: String,
}
#[derive(Serialize, Clone)]
pub struct PrivateMessagesResponse {
pub private_messages: Vec<PrivateMessageView>,
}
#[derive(Serialize, Clone)]
pub struct PrivateMessageResponse {
pub private_message_view: PrivateMessageView,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct GetReportCount {
pub community: Option<CommunityId>,
pub auth: String,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct GetReportCountResponse {
pub community: Option<CommunityId>,
pub comment_reports: i64,
pub post_reports: i64,
}