2021-01-27 16:42:23 +00:00
|
|
|
use crate::{
|
|
|
|
schema::{user_, user_alias_1, user_alias_2},
|
|
|
|
Url,
|
|
|
|
};
|
2020-12-18 18:38:32 +00:00
|
|
|
use serde::Serialize;
|
|
|
|
|
|
|
|
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
|
|
|
#[table_name = "user_"]
|
|
|
|
pub struct User_ {
|
|
|
|
pub id: i32,
|
|
|
|
pub name: String,
|
|
|
|
pub preferred_username: Option<String>,
|
|
|
|
pub password_encrypted: String,
|
|
|
|
pub email: Option<String>,
|
|
|
|
pub avatar: Option<String>,
|
|
|
|
pub admin: bool,
|
|
|
|
pub banned: bool,
|
|
|
|
pub published: chrono::NaiveDateTime,
|
|
|
|
pub updated: Option<chrono::NaiveDateTime>,
|
|
|
|
pub show_nsfw: bool,
|
|
|
|
pub theme: String,
|
|
|
|
pub default_sort_type: i16,
|
|
|
|
pub default_listing_type: i16,
|
|
|
|
pub lang: String,
|
|
|
|
pub show_avatars: bool,
|
|
|
|
pub send_notifications_to_email: bool,
|
|
|
|
pub matrix_user_id: Option<String>,
|
2021-01-27 16:42:23 +00:00
|
|
|
pub actor_id: Url,
|
2020-12-18 18:38:32 +00:00
|
|
|
pub bio: Option<String>,
|
|
|
|
pub local: bool,
|
|
|
|
pub private_key: Option<String>,
|
|
|
|
pub public_key: Option<String>,
|
|
|
|
pub last_refreshed_at: chrono::NaiveDateTime,
|
|
|
|
pub banner: Option<String>,
|
|
|
|
pub deleted: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// A safe representation of user, without the sensitive info
|
|
|
|
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
|
|
|
#[table_name = "user_"]
|
|
|
|
pub struct UserSafe {
|
|
|
|
pub id: i32,
|
|
|
|
pub name: String,
|
|
|
|
pub preferred_username: Option<String>,
|
|
|
|
pub avatar: Option<String>,
|
|
|
|
pub admin: bool,
|
|
|
|
pub banned: bool,
|
|
|
|
pub published: chrono::NaiveDateTime,
|
|
|
|
pub updated: Option<chrono::NaiveDateTime>,
|
|
|
|
pub matrix_user_id: Option<String>,
|
2021-01-27 16:42:23 +00:00
|
|
|
pub actor_id: Url,
|
2020-12-18 18:38:32 +00:00
|
|
|
pub bio: Option<String>,
|
|
|
|
pub local: bool,
|
|
|
|
pub banner: Option<String>,
|
|
|
|
pub deleted: bool,
|
|
|
|
}
|
|
|
|
|
2021-01-18 21:57:31 +00:00
|
|
|
/// A safe user view with only settings
|
|
|
|
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
|
|
|
#[table_name = "user_"]
|
|
|
|
pub struct UserSafeSettings {
|
|
|
|
pub id: i32,
|
|
|
|
pub name: String,
|
|
|
|
pub preferred_username: Option<String>,
|
|
|
|
pub email: Option<String>,
|
|
|
|
pub avatar: Option<String>,
|
|
|
|
pub admin: bool,
|
|
|
|
pub banned: bool,
|
|
|
|
pub published: chrono::NaiveDateTime,
|
|
|
|
pub updated: Option<chrono::NaiveDateTime>,
|
|
|
|
pub show_nsfw: bool,
|
|
|
|
pub theme: String,
|
|
|
|
pub default_sort_type: i16,
|
|
|
|
pub default_listing_type: i16,
|
|
|
|
pub lang: String,
|
|
|
|
pub show_avatars: bool,
|
|
|
|
pub send_notifications_to_email: bool,
|
|
|
|
pub matrix_user_id: Option<String>,
|
2021-01-27 16:42:23 +00:00
|
|
|
pub actor_id: Url,
|
2021-01-18 21:57:31 +00:00
|
|
|
pub bio: Option<String>,
|
|
|
|
pub local: bool,
|
|
|
|
pub last_refreshed_at: chrono::NaiveDateTime,
|
|
|
|
pub banner: Option<String>,
|
|
|
|
pub deleted: bool,
|
|
|
|
}
|
|
|
|
|
2020-12-18 18:38:32 +00:00
|
|
|
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
|
|
|
#[table_name = "user_alias_1"]
|
|
|
|
pub struct UserAlias1 {
|
|
|
|
pub id: i32,
|
|
|
|
pub name: String,
|
|
|
|
pub preferred_username: Option<String>,
|
|
|
|
pub password_encrypted: String,
|
|
|
|
pub email: Option<String>,
|
|
|
|
pub avatar: Option<String>,
|
|
|
|
pub admin: bool,
|
|
|
|
pub banned: bool,
|
|
|
|
pub published: chrono::NaiveDateTime,
|
|
|
|
pub updated: Option<chrono::NaiveDateTime>,
|
|
|
|
pub show_nsfw: bool,
|
|
|
|
pub theme: String,
|
|
|
|
pub default_sort_type: i16,
|
|
|
|
pub default_listing_type: i16,
|
|
|
|
pub lang: String,
|
|
|
|
pub show_avatars: bool,
|
|
|
|
pub send_notifications_to_email: bool,
|
|
|
|
pub matrix_user_id: Option<String>,
|
2021-01-27 16:42:23 +00:00
|
|
|
pub actor_id: Url,
|
2020-12-18 18:38:32 +00:00
|
|
|
pub bio: Option<String>,
|
|
|
|
pub local: bool,
|
|
|
|
pub private_key: Option<String>,
|
|
|
|
pub public_key: Option<String>,
|
|
|
|
pub last_refreshed_at: chrono::NaiveDateTime,
|
|
|
|
pub banner: Option<String>,
|
|
|
|
pub deleted: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
|
|
|
#[table_name = "user_alias_1"]
|
|
|
|
pub struct UserSafeAlias1 {
|
|
|
|
pub id: i32,
|
|
|
|
pub name: String,
|
|
|
|
pub preferred_username: Option<String>,
|
|
|
|
pub avatar: Option<String>,
|
|
|
|
pub admin: bool,
|
|
|
|
pub banned: bool,
|
|
|
|
pub published: chrono::NaiveDateTime,
|
|
|
|
pub updated: Option<chrono::NaiveDateTime>,
|
|
|
|
pub matrix_user_id: Option<String>,
|
2021-01-27 16:42:23 +00:00
|
|
|
pub actor_id: Url,
|
2020-12-18 18:38:32 +00:00
|
|
|
pub bio: Option<String>,
|
|
|
|
pub local: bool,
|
|
|
|
pub banner: Option<String>,
|
|
|
|
pub deleted: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
|
|
|
#[table_name = "user_alias_2"]
|
|
|
|
pub struct UserAlias2 {
|
|
|
|
pub id: i32,
|
|
|
|
pub name: String,
|
|
|
|
pub preferred_username: Option<String>,
|
|
|
|
pub password_encrypted: String,
|
|
|
|
pub email: Option<String>,
|
|
|
|
pub avatar: Option<String>,
|
|
|
|
pub admin: bool,
|
|
|
|
pub banned: bool,
|
|
|
|
pub published: chrono::NaiveDateTime,
|
|
|
|
pub updated: Option<chrono::NaiveDateTime>,
|
|
|
|
pub show_nsfw: bool,
|
|
|
|
pub theme: String,
|
|
|
|
pub default_sort_type: i16,
|
|
|
|
pub default_listing_type: i16,
|
|
|
|
pub lang: String,
|
|
|
|
pub show_avatars: bool,
|
|
|
|
pub send_notifications_to_email: bool,
|
|
|
|
pub matrix_user_id: Option<String>,
|
2021-01-27 16:42:23 +00:00
|
|
|
pub actor_id: Url,
|
2020-12-18 18:38:32 +00:00
|
|
|
pub bio: Option<String>,
|
|
|
|
pub local: bool,
|
|
|
|
pub private_key: Option<String>,
|
|
|
|
pub public_key: Option<String>,
|
|
|
|
pub last_refreshed_at: chrono::NaiveDateTime,
|
|
|
|
pub banner: Option<String>,
|
|
|
|
pub deleted: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
|
|
|
#[table_name = "user_alias_2"]
|
|
|
|
pub struct UserSafeAlias2 {
|
|
|
|
pub id: i32,
|
|
|
|
pub name: String,
|
|
|
|
pub preferred_username: Option<String>,
|
|
|
|
pub avatar: Option<String>,
|
|
|
|
pub admin: bool,
|
|
|
|
pub banned: bool,
|
|
|
|
pub published: chrono::NaiveDateTime,
|
|
|
|
pub updated: Option<chrono::NaiveDateTime>,
|
|
|
|
pub matrix_user_id: Option<String>,
|
2021-01-27 16:42:23 +00:00
|
|
|
pub actor_id: Url,
|
2020-12-18 18:38:32 +00:00
|
|
|
pub bio: Option<String>,
|
|
|
|
pub local: bool,
|
|
|
|
pub banner: Option<String>,
|
|
|
|
pub deleted: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Insertable, AsChangeset, Clone)]
|
|
|
|
#[table_name = "user_"]
|
|
|
|
pub struct UserForm {
|
|
|
|
pub name: String,
|
|
|
|
pub preferred_username: Option<Option<String>>,
|
|
|
|
pub password_encrypted: String,
|
|
|
|
pub admin: bool,
|
|
|
|
pub banned: Option<bool>,
|
|
|
|
pub email: Option<Option<String>>,
|
|
|
|
pub avatar: Option<Option<String>>,
|
|
|
|
pub published: Option<chrono::NaiveDateTime>,
|
|
|
|
pub updated: Option<chrono::NaiveDateTime>,
|
|
|
|
pub show_nsfw: bool,
|
|
|
|
pub theme: String,
|
|
|
|
pub default_sort_type: i16,
|
|
|
|
pub default_listing_type: i16,
|
|
|
|
pub lang: String,
|
|
|
|
pub show_avatars: bool,
|
|
|
|
pub send_notifications_to_email: bool,
|
|
|
|
pub matrix_user_id: Option<Option<String>>,
|
2021-01-27 16:42:23 +00:00
|
|
|
pub actor_id: Option<Url>,
|
2020-12-18 18:38:32 +00:00
|
|
|
pub bio: Option<Option<String>>,
|
|
|
|
pub local: bool,
|
|
|
|
pub private_key: Option<String>,
|
|
|
|
pub public_key: Option<String>,
|
|
|
|
pub last_refreshed_at: Option<chrono::NaiveDateTime>,
|
|
|
|
pub banner: Option<Option<String>>,
|
|
|
|
}
|