130 lines
2.8 KiB
Rust
130 lines
2.8 KiB
Rust
use crate::endpoints::{Empty, Endpoint};
|
|
use crate::util_types::deserialize_array_urlenc;
|
|
use http::Method;
|
|
use magnetar_sdk_macros::Endpoint;
|
|
use serde::{Deserialize, Serialize};
|
|
use ts_rs::TS;
|
|
|
|
use crate::types::user::{PackUserBase, PackUserMaybeAll, PackUserSelfMaybeAll};
|
|
|
|
// Get self
|
|
#[derive(Serialize, Deserialize, TS)]
|
|
#[ts(export)]
|
|
pub struct UserSelfReq {
|
|
#[ts(optional)]
|
|
pub profile: Option<bool>,
|
|
#[ts(optional)]
|
|
pub pins: Option<bool>,
|
|
#[ts(optional)]
|
|
pub detail: Option<bool>,
|
|
#[ts(optional)]
|
|
pub secrets: Option<bool>,
|
|
}
|
|
|
|
#[derive(Endpoint)]
|
|
#[endpoint(
|
|
endpoint = "/users/@self",
|
|
method = Method::GET,
|
|
request = "UserSelfReq",
|
|
response = "PackUserSelfMaybeAll"
|
|
)]
|
|
pub struct GetUserSelf;
|
|
|
|
// Get user by id
|
|
#[derive(Serialize, Deserialize, TS)]
|
|
#[ts(export)]
|
|
pub struct UserByIdReq {
|
|
#[ts(optional)]
|
|
pub profile: Option<bool>,
|
|
#[ts(optional)]
|
|
pub pins: Option<bool>,
|
|
#[ts(optional)]
|
|
pub detail: Option<bool>,
|
|
#[ts(optional)]
|
|
pub relation: Option<bool>,
|
|
#[ts(optional)]
|
|
pub auth: Option<bool>,
|
|
}
|
|
|
|
#[derive(Endpoint)]
|
|
#[endpoint(
|
|
endpoint = "/users/:user_id",
|
|
method = Method::GET,
|
|
request = "UserByIdReq",
|
|
response = "PackUserMaybeAll"
|
|
)]
|
|
pub struct GetUserById;
|
|
|
|
// Get many users by an ID array
|
|
#[derive(Serialize, Deserialize, TS)]
|
|
#[ts(export)]
|
|
pub struct ManyUsersByIdReq {
|
|
#[serde(deserialize_with = "deserialize_array_urlenc")]
|
|
pub id: Vec<String>,
|
|
}
|
|
|
|
#[derive(Endpoint)]
|
|
#[endpoint(
|
|
endpoint = "/users/lookup-many",
|
|
method = Method::GET,
|
|
request = "ManyUsersByIdReq",
|
|
response = "Vec<Option<PackUserBase>>"
|
|
)]
|
|
pub struct GetManyUsersById;
|
|
|
|
// Get user by fedi tag
|
|
|
|
#[derive(Endpoint)]
|
|
#[endpoint(
|
|
endpoint = "/users/by-acct/:user_acct",
|
|
method = Method::GET,
|
|
request = "UserByIdReq",
|
|
response = "PackUserMaybeAll"
|
|
)]
|
|
pub struct GetUserByAcct;
|
|
|
|
#[derive(Endpoint)]
|
|
#[endpoint(
|
|
endpoint = "/users/:id/followers",
|
|
method = Method::GET,
|
|
request = "Empty",
|
|
response = "Vec<PackUserBase>"
|
|
)]
|
|
pub struct GetFollowersById;
|
|
|
|
#[derive(Endpoint)]
|
|
#[endpoint(
|
|
endpoint = "/users/:id/following",
|
|
method = Method::GET,
|
|
request = "Empty",
|
|
response = "Vec<PackUserBase>"
|
|
)]
|
|
pub struct GetFollowingById;
|
|
|
|
#[derive(Endpoint)]
|
|
#[endpoint(
|
|
endpoint = "/users/@self/followers",
|
|
method = Method::GET,
|
|
request = "Empty",
|
|
response = "Vec<PackUserBase>"
|
|
)]
|
|
pub struct GetFollowersSelf;
|
|
|
|
#[derive(Endpoint)]
|
|
#[endpoint(
|
|
endpoint = "/users/@self/following",
|
|
method = Method::GET,
|
|
request = "Empty",
|
|
response = "Vec<PackUserBase>"
|
|
)]
|
|
pub struct GetFollowingSelf;
|
|
|
|
#[derive(Endpoint)]
|
|
#[endpoint(
|
|
endpoint = "/users/@self/follow-requests",
|
|
method = Method::GET,
|
|
request = "Empty",
|
|
response = "Vec<PackUserBase>"
|
|
)]
|
|
pub struct GetFollowRequestsSelf;
|