2020-09-01 14:25:34 +00:00
|
|
|
use lemmy_db::{
|
|
|
|
private_message_view::PrivateMessageView,
|
2020-12-06 14:12:51 +00:00
|
|
|
views::{
|
2020-12-15 19:39:18 +00:00
|
|
|
comment_view::CommentView,
|
2020-12-06 14:12:51 +00:00
|
|
|
community_follower_view::CommunityFollowerView,
|
|
|
|
community_moderator_view::CommunityModeratorView,
|
2020-12-11 15:27:33 +00:00
|
|
|
post_view::PostView,
|
2020-12-16 16:09:21 +00:00
|
|
|
user_mention_view::UserMentionView,
|
2020-12-06 14:12:51 +00:00
|
|
|
user_view::{UserViewDangerous, UserViewSafe},
|
|
|
|
},
|
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,
|
|
|
|
}
|
|
|
|
|
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 admin: bool,
|
|
|
|
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 {
|
|
|
|
pub ok: Option<CaptchaResponse>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct CaptchaResponse {
|
|
|
|
pub png: String, // A Base64 encoded png
|
|
|
|
pub wav: Option<String>, // A Base64 encoded wav audio
|
|
|
|
pub uuid: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct SaveUserSettings {
|
|
|
|
pub show_nsfw: bool,
|
|
|
|
pub theme: String,
|
|
|
|
pub default_sort_type: i16,
|
|
|
|
pub default_listing_type: i16,
|
|
|
|
pub lang: String,
|
|
|
|
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>,
|
|
|
|
pub show_avatars: bool,
|
|
|
|
pub send_notifications_to_email: bool,
|
|
|
|
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)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetUserDetails {
|
|
|
|
pub user_id: Option<i32>,
|
|
|
|
pub username: Option<String>,
|
|
|
|
pub sort: String,
|
|
|
|
pub page: Option<i64>,
|
|
|
|
pub limit: Option<i64>,
|
|
|
|
pub community_id: Option<i32>,
|
|
|
|
pub saved_only: bool,
|
|
|
|
pub auth: Option<String>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetUserDetailsResponse {
|
2020-12-04 00:47:58 +00:00
|
|
|
pub user: Option<UserViewSafe>,
|
|
|
|
pub user_dangerous: Option<UserViewDangerous>,
|
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)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetUserMentionsResponse {
|
|
|
|
pub mentions: Vec<UserMentionView>,
|
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
pub user_id: i32,
|
|
|
|
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 {
|
2020-12-04 00:47:58 +00:00
|
|
|
pub admins: Vec<UserViewSafe>,
|
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 BanUser {
|
|
|
|
pub user_id: i32,
|
|
|
|
pub ban: bool,
|
|
|
|
pub remove_data: Option<bool>,
|
|
|
|
pub reason: Option<String>,
|
|
|
|
pub expires: 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 BanUserResponse {
|
2020-12-04 00:47:58 +00:00
|
|
|
pub user: UserViewSafe,
|
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)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct GetUserMentions {
|
|
|
|
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)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct MarkUserMentionAsRead {
|
|
|
|
pub user_mention_id: i32,
|
|
|
|
pub read: 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 UserMentionResponse {
|
2020-12-16 16:09:21 +00:00
|
|
|
pub user_mention_view: UserMentionView,
|
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,
|
|
|
|
pub recipient_id: i32,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct EditPrivateMessage {
|
|
|
|
pub edit_id: i32,
|
|
|
|
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 {
|
|
|
|
pub edit_id: i32,
|
|
|
|
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 {
|
|
|
|
pub edit_id: i32,
|
|
|
|
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 {
|
|
|
|
pub messages: Vec<PrivateMessageView>,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct PrivateMessageResponse {
|
|
|
|
pub message: PrivateMessageView,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Deserialize, Debug)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct UserJoin {
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
2020-09-03 19:45:12 +00:00
|
|
|
#[derive(Serialize, Clone)]
|
2020-09-01 14:25:34 +00:00
|
|
|
pub struct UserJoinResponse {
|
2020-09-15 19:26:47 +00:00
|
|
|
pub joined: bool,
|
2020-09-01 14:25:34 +00:00
|
|
|
}
|
2020-10-25 02:59:13 +00:00
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub struct GetReportCount {
|
|
|
|
pub community: Option<i32>,
|
|
|
|
pub auth: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
|
|
|
pub struct GetReportCountResponse {
|
|
|
|
pub community: Option<i32>,
|
2020-11-04 02:15:11 +00:00
|
|
|
pub comment_reports: i64,
|
|
|
|
pub post_reports: i64,
|
2020-10-25 02:59:13 +00:00
|
|
|
}
|