113 lines
2.9 KiB
Rust
113 lines
2.9 KiB
Rust
use crate::types::emoji::EmojiContext;
|
|
use crate::types::user::{PackUserBase, UserBase};
|
|
use crate::types::Id;
|
|
use crate::{Packed, Required};
|
|
use chrono::{DateTime, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
use ts_rs::TS;
|
|
|
|
use crate::types::drive::PackDriveFileBase;
|
|
|
|
use magnetar_sdk_macros::pack;
|
|
|
|
#[derive(Copy, Clone, Default, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct NoteListFilter {
|
|
show_renotes: Option<bool>,
|
|
show_replies: Option<bool>,
|
|
show_files_only: Option<bool>,
|
|
uncwed_sensitive: Option<bool>,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub enum NoteVisibility {
|
|
Public,
|
|
Home,
|
|
Followers,
|
|
Direct,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct PollChoice {
|
|
pub title: String,
|
|
pub votes_count: u64,
|
|
pub voted: bool,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct PollBase {
|
|
pub expires_at: DateTime<Utc>,
|
|
pub expired: bool,
|
|
pub multiple_choice: bool,
|
|
pub options: Vec<PollChoice>,
|
|
}
|
|
|
|
pack!(PackPollBase, Required<Id> as id & Required<PollBase> as poll);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct NoteBase {
|
|
pub created_at: DateTime<Utc>,
|
|
pub cw: Option<String>,
|
|
pub uri: Option<String>,
|
|
pub url: Option<String>,
|
|
pub text: String,
|
|
pub visibility: NoteVisibility,
|
|
pub user: Box<UserBase>,
|
|
pub parent_note_id: Option<String>,
|
|
pub renoted_note_id: Option<String>,
|
|
pub reply_count: u64,
|
|
pub renote_count: u64,
|
|
pub hashtags: Vec<String>,
|
|
pub reactions: Vec<PackReactionBase>,
|
|
pub emojis: EmojiContext,
|
|
pub local_only: bool,
|
|
}
|
|
|
|
pack!(PackNoteBase, Required<Id> as id & Required<NoteBase> as note);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct NoteAttachmentExt {
|
|
pub attachments: Vec<PackDriveFileBase>,
|
|
pub poll: Option<PollBase>,
|
|
}
|
|
|
|
pack!(
|
|
PackNoteWithAttachments,
|
|
Required<Id> as id & Required<NoteBase> as note & Required<NoteAttachmentExt> as attachment
|
|
);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
pub struct NoteDetailExt {
|
|
pub poll: Option<PackPollBase>,
|
|
pub parent_note: Option<Box<NoteBase>>,
|
|
pub renoted_note: Option<Box<NoteBase>>,
|
|
}
|
|
|
|
pack!(
|
|
PackNoteFull,
|
|
Required<Id> as id & Required<NoteBase> as note & Required<NoteAttachmentExt> as attachment & Required<NoteDetailExt> as detail
|
|
);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
pub struct ReactionBase {
|
|
pub created_at: DateTime<Utc>,
|
|
pub user_id: String,
|
|
}
|
|
|
|
pack!(PackReactionBase, Required<Id> as id & Required<ReactionBase> as reaction);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
pub struct ReactionUserExt {
|
|
pub user: Box<PackUserBase>,
|
|
}
|
|
|
|
pack!(
|
|
PackReactionWithUser,
|
|
Required<Id> as id & Required<ReactionBase> as reaction & Required<ReactionUserExt> as user
|
|
);
|