188 lines
4.5 KiB
Rust
188 lines
4.5 KiB
Rust
use crate::types::emoji::EmojiContext;
|
|
use crate::types::note::PackNoteBase;
|
|
use crate::types::{Id, NotificationSettings};
|
|
use chrono::{DateTime, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
use ts_rs::TS;
|
|
|
|
use magnetar_sdk_macros::pack;
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub enum AvatarDecoration {
|
|
None,
|
|
CatEars,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub enum SpeechTransform {
|
|
None,
|
|
Cat,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct ProfileField {
|
|
name: String,
|
|
value: String,
|
|
verified_at: Option<DateTime<Utc>>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct UserBase {
|
|
pub acct: String,
|
|
pub username: String,
|
|
pub display_name: String,
|
|
pub host: Option<String>,
|
|
pub speech_transform: SpeechTransform,
|
|
pub created_at: DateTime<Utc>,
|
|
pub avatar_url: Option<String>,
|
|
pub avatar_blurhash: Option<String>,
|
|
pub avatar_color: Option<String>,
|
|
pub avatar_decoration: AvatarDecoration,
|
|
pub admin: bool,
|
|
pub moderator: bool,
|
|
pub bot: bool,
|
|
pub emojis: EmojiContext,
|
|
}
|
|
|
|
pack!(PackUserBase, Id as id & UserBase as user);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct UserProfileExt {
|
|
pub locked: bool,
|
|
pub silenced: bool,
|
|
pub suspended: bool,
|
|
|
|
pub description: Option<String>,
|
|
pub location: Option<String>,
|
|
pub birthday: Option<DateTime<Utc>>,
|
|
pub fields: Vec<ProfileField>,
|
|
|
|
pub follower_count: u64,
|
|
pub following_count: u64,
|
|
pub note_count: u64,
|
|
|
|
pub url: Option<String>,
|
|
|
|
pub moved_to_uri: Option<String>,
|
|
pub also_known_as: Option<String>,
|
|
|
|
pub banner_url: Option<String>,
|
|
pub banner_color: Option<String>,
|
|
pub banner_blurhash: Option<String>,
|
|
|
|
pub public_reactions: bool,
|
|
}
|
|
|
|
pack!(
|
|
PackUserProfile,
|
|
Id as id & UserBase as user & UserProfileExt as profile
|
|
);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct UserProfilePinsEx {
|
|
pub pinned_notes: Vec<PackNoteBase>,
|
|
// pub pinned_page: Option<Page>,
|
|
}
|
|
|
|
pack!(
|
|
PackUserProfileFull,
|
|
Id as id
|
|
& UserBase as user
|
|
& UserProfileExt as profile
|
|
& UserProfilePinsEx as pins
|
|
& UserRelationExt as relation
|
|
);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct UserRelationExt {
|
|
pub last_fetched_at: Option<DateTime<Utc>>,
|
|
pub follows_you: bool,
|
|
pub you_follow: bool,
|
|
pub blocks_you: bool,
|
|
pub you_block: bool,
|
|
pub mute: bool,
|
|
pub mute_renotes: bool,
|
|
}
|
|
|
|
pack!(
|
|
PackUserRelation,
|
|
Id as id & UserBase as user & UserRelationExt as relation
|
|
);
|
|
pack!(
|
|
PackUserProfileRelation,
|
|
Id as id & UserBase as user & UserProfileExt as profile & UserRelationExt as relation
|
|
);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct UserAuthOverviewExt {
|
|
pub two_factor_enabled: bool,
|
|
pub use_passwordless_login: bool,
|
|
pub security_keys: bool,
|
|
}
|
|
|
|
pack!(
|
|
PackUserAuthOverview,
|
|
Id as id & UserBase as user & UserAuthOverviewExt as auth
|
|
);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct UserSelfExt {
|
|
pub avatar_id: Option<String>,
|
|
pub banner_id: Option<String>,
|
|
pub email_announcements: bool,
|
|
pub always_mark_sensitive: bool,
|
|
pub reject_bot_follow_requests: bool,
|
|
pub reject_crawlers: bool,
|
|
pub reject_ai_training: bool,
|
|
pub has_unread_announcements: bool,
|
|
pub has_unread_antenna: bool,
|
|
pub has_unread_notifications: bool,
|
|
pub has_pending_follow_requests: bool,
|
|
pub word_mutes: Vec<String>,
|
|
pub instance_mutes: Vec<String>,
|
|
pub notification_settings: NotificationSettings,
|
|
}
|
|
|
|
pack!(
|
|
PackUserSelf,
|
|
Id as id & UserBase as user & UserSelfExt as self_info
|
|
);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct UserDetailExt {
|
|
pub uri: Option<String>,
|
|
pub updated_at: Option<DateTime<Utc>>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct SecurityKeyBase {
|
|
pub name: String,
|
|
pub created_at: DateTime<Utc>,
|
|
pub last_used_at: Option<DateTime<Utc>>,
|
|
}
|
|
|
|
pack!(PackSecurityKeyBase, Id as id & SecurityKeyBase as key);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct UserSecretsExt {
|
|
pub email: Option<String>,
|
|
pub email_verified: bool,
|
|
pub security_keys: Vec<SecurityKeyBase>,
|
|
}
|
|
pack!(
|
|
PackUserSelfAll,
|
|
Id as id & UserBase as user & UserSelfExt as self_info & UserSecretsExt as secrets
|
|
);
|