36 lines
894 B
Rust
36 lines
894 B
Rust
use crate::endpoints::Endpoint;
|
|
use crate::types::note::{NoteListFilter, PackNoteFull};
|
|
use crate::util_types::U64Range;
|
|
use http::Method;
|
|
use magnetar_sdk_macros::Endpoint;
|
|
use serde::{Deserialize, Serialize};
|
|
use ts_rs::TS;
|
|
|
|
// Get timeline notes
|
|
#[derive(Serialize, Deserialize, TS)]
|
|
#[ts(export)]
|
|
pub struct GetTimelineReq {
|
|
#[serde(default = "default_timeline_limit")]
|
|
pub limit: U64Range<1, 100>,
|
|
#[serde(flatten)]
|
|
pub filter: Option<NoteListFilter>,
|
|
}
|
|
|
|
fn default_timeline_limit<const MIN: u64, const MAX: u64>() -> U64Range<MIN, MAX> {
|
|
15.try_into().unwrap()
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, TS)]
|
|
#[ts(export)]
|
|
#[serde(transparent)]
|
|
pub struct GetTimelineRes(pub Vec<PackNoteFull>);
|
|
|
|
#[derive(Endpoint)]
|
|
#[endpoint(
|
|
endpoint = "/timeline",
|
|
method = Method::GET,
|
|
request = GetTimelineReq,
|
|
response = Vec::<PackNoteFull>,
|
|
)]
|
|
pub struct GetTimeline;
|