104 lines
2.4 KiB
Rust
104 lines
2.4 KiB
Rust
use crate::types::emoji::EmojiContext;
|
|
use crate::types::user::{PackUserBase, UserBase};
|
|
use crate::types::Id;
|
|
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, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub enum NoteVisibility {
|
|
Public,
|
|
Home,
|
|
Followers,
|
|
Specified,
|
|
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, Id as id & 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, Id as id & NoteBase as note);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
#[ts(export)]
|
|
pub struct NoteAttachmentExt {
|
|
pub attachments: Vec<PackDriveFileBase>,
|
|
pub poll: Option<PollBase>,
|
|
}
|
|
|
|
pack!(
|
|
PackNoteWithAttachments,
|
|
Id as id & NoteBase as note & NoteAttachmentExt as attachment
|
|
);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
pub struct NoteDetailExt {
|
|
pub poll: Option<PollBase>,
|
|
pub parent_note: Option<Box<NoteBase>>,
|
|
pub renoted_note: Option<Box<NoteBase>>,
|
|
}
|
|
|
|
pack!(
|
|
PackNoteFull,
|
|
Id as id & NoteBase as note & NoteAttachmentExt as attachment & NoteDetailExt as detail
|
|
);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
pub struct ReactionBase {
|
|
pub created_at: DateTime<Utc>,
|
|
pub user_id: String,
|
|
}
|
|
|
|
pack!(PackReactionBase, Id as id & ReactionBase as reaction);
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
|
|
pub struct ReactionUserExt {
|
|
pub user: Box<PackUserBase>,
|
|
}
|
|
|
|
pack!(
|
|
PackReactionWithUser,
|
|
Id as id & ReactionBase as reaction & ReactionUserExt as user
|
|
);
|