style: cargo clippy && cargo fmt
This commit is contained in:
parent
c9a3e8c6c4
commit
d615f1392e
31 changed files with 288 additions and 181 deletions
|
@ -7,5 +7,7 @@ mod v1;
|
|||
mod versions;
|
||||
|
||||
pub fn web(path: &str) -> Scope {
|
||||
web::scope(path.trim_end_matches('/')).service(v1::web()).service(versions::get)
|
||||
web::scope(path.trim_end_matches('/'))
|
||||
.service(v1::web())
|
||||
.service(versions::get)
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ use crate::{
|
|||
error::Error,
|
||||
schema::*,
|
||||
utils::{
|
||||
PASSWORD_REGEX, generate_access_token, generate_refresh_token,
|
||||
refresh_token_cookie, user_uuid_from_identifier
|
||||
PASSWORD_REGEX, generate_access_token, generate_refresh_token, refresh_token_cookie,
|
||||
user_uuid_from_identifier,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ use crate::{Conn, error::Error, schema::access_tokens::dsl};
|
|||
mod login;
|
||||
mod refresh;
|
||||
mod register;
|
||||
mod reset_password;
|
||||
mod revoke;
|
||||
mod verify_email;
|
||||
mod reset_password;
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct Response {
|
||||
|
|
|
@ -61,8 +61,6 @@ pub async fn res(req: HttpRequest, data: web::Data<Data>) -> Result<HttpResponse
|
|||
if lifetime > 1987200 {
|
||||
let new_refresh_token = generate_refresh_token()?;
|
||||
|
||||
let new_refresh_token = new_refresh_token;
|
||||
|
||||
match update(refresh_tokens::table)
|
||||
.filter(rdsl::token.eq(&refresh_token))
|
||||
.set((
|
||||
|
|
|
@ -4,9 +4,7 @@ use actix_web::{HttpResponse, get, post, web};
|
|||
use chrono::{Duration, Utc};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
error::Error, structs::PasswordResetToken, Data
|
||||
};
|
||||
use crate::{Data, error::Error, structs::PasswordResetToken};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Query {
|
||||
|
@ -14,30 +12,31 @@ struct Query {
|
|||
}
|
||||
|
||||
/// `GET /api/v1/auth/reset-password` Sends password reset email to user
|
||||
///
|
||||
///
|
||||
/// requires auth? no
|
||||
///
|
||||
///
|
||||
/// ### Query Parameters
|
||||
/// identifier: Email or username
|
||||
///
|
||||
///
|
||||
/// ### Responses
|
||||
/// 200 Email sent
|
||||
/// 429 Too Many Requests
|
||||
/// 404 Not found
|
||||
/// 400 Bad request
|
||||
///
|
||||
///
|
||||
#[get("/reset-password")]
|
||||
pub async fn get(
|
||||
query: web::Query<Query>,
|
||||
data: web::Data<Data>,
|
||||
) -> Result<HttpResponse, Error> {
|
||||
pub async fn get(query: web::Query<Query>, data: web::Data<Data>) -> Result<HttpResponse, Error> {
|
||||
let mut conn = data.pool.get().await?;
|
||||
|
||||
if let Ok(password_reset_token) = PasswordResetToken::get_with_identifier(&mut conn, query.identifier.clone()).await {
|
||||
if let Ok(password_reset_token) =
|
||||
PasswordResetToken::get_with_identifier(&mut conn, query.identifier.clone()).await
|
||||
{
|
||||
if Utc::now().signed_duration_since(password_reset_token.created_at) > Duration::hours(1) {
|
||||
password_reset_token.delete(&mut conn).await?;
|
||||
} else {
|
||||
return Err(Error::TooManyRequests("Please allow 1 hour before sending a new email".to_string()))
|
||||
return Err(Error::TooManyRequests(
|
||||
"Please allow 1 hour before sending a new email".to_string(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,9 +52,9 @@ struct ResetPassword {
|
|||
}
|
||||
|
||||
/// `POST /api/v1/auth/reset-password` Resets user password
|
||||
///
|
||||
///
|
||||
/// requires auth? no
|
||||
///
|
||||
///
|
||||
/// ### Request Example:
|
||||
/// ```
|
||||
/// json!({
|
||||
|
@ -63,13 +62,13 @@ struct ResetPassword {
|
|||
/// "token": "a3f7e29c1b8d0456e2c9f83b7a1d6e4f5028c3b9a7e1f2d5c6b8a0d3e7f4a2b"
|
||||
/// });
|
||||
/// ```
|
||||
///
|
||||
///
|
||||
/// ### Responses
|
||||
/// 200 Success
|
||||
/// 410 Token Expired
|
||||
/// 404 Not Found
|
||||
/// 400 Bad Request
|
||||
///
|
||||
///
|
||||
#[post("/reset-password")]
|
||||
pub async fn post(
|
||||
reset_password: web::Json<ResetPassword>,
|
||||
|
@ -77,14 +76,17 @@ pub async fn post(
|
|||
) -> Result<HttpResponse, Error> {
|
||||
let mut conn = data.pool.get().await?;
|
||||
|
||||
let password_reset_token = PasswordResetToken::get(&mut conn, reset_password.token.clone()).await?;
|
||||
let password_reset_token =
|
||||
PasswordResetToken::get(&mut conn, reset_password.token.clone()).await?;
|
||||
|
||||
if Utc::now().signed_duration_since(password_reset_token.created_at) > Duration::hours(24) {
|
||||
password_reset_token.delete(&mut conn).await?;
|
||||
return Ok(HttpResponse::Gone().finish());
|
||||
}
|
||||
|
||||
password_reset_token.set_password(&data, reset_password.password.clone()).await?;
|
||||
password_reset_token
|
||||
.set_password(&data, reset_password.password.clone())
|
||||
.await?;
|
||||
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
|
|
|
@ -5,7 +5,11 @@ use chrono::{Duration, Utc};
|
|||
use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
api::v1::auth::check_access_token, error::Error, structs::{EmailToken, Me}, utils::get_auth_header, Data
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
structs::{EmailToken, Me},
|
||||
utils::get_auth_header,
|
||||
};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
@ -14,18 +18,18 @@ struct Query {
|
|||
}
|
||||
|
||||
/// `GET /api/v1/auth/verify-email` Verifies user email address
|
||||
///
|
||||
///
|
||||
/// requires auth? yes
|
||||
///
|
||||
///
|
||||
/// ### Query Parameters
|
||||
/// token
|
||||
///
|
||||
///
|
||||
/// ### Responses
|
||||
/// 200 Success
|
||||
/// 410 Token Expired
|
||||
/// 404 Not Found
|
||||
/// 401 Unauthorized
|
||||
///
|
||||
///
|
||||
#[get("/verify-email")]
|
||||
pub async fn get(
|
||||
req: HttpRequest,
|
||||
|
@ -61,20 +65,17 @@ pub async fn get(
|
|||
}
|
||||
|
||||
/// `POST /api/v1/auth/verify-email` Sends user verification email
|
||||
///
|
||||
///
|
||||
/// requires auth? yes
|
||||
///
|
||||
///
|
||||
/// ### Responses
|
||||
/// 200 Email sent
|
||||
/// 204 Already verified
|
||||
/// 429 Too Many Requests
|
||||
/// 401 Unauthorized
|
||||
///
|
||||
///
|
||||
#[post("/verify-email")]
|
||||
pub async fn post(
|
||||
req: HttpRequest,
|
||||
data: web::Data<Data>,
|
||||
) -> Result<HttpResponse, Error> {
|
||||
pub async fn post(req: HttpRequest, data: web::Data<Data>) -> Result<HttpResponse, Error> {
|
||||
let headers = req.headers();
|
||||
|
||||
let auth_header = get_auth_header(headers)?;
|
||||
|
@ -86,14 +87,16 @@ pub async fn post(
|
|||
let me = Me::get(&mut conn, uuid).await?;
|
||||
|
||||
if me.email_verified {
|
||||
return Ok(HttpResponse::NoContent().finish())
|
||||
return Ok(HttpResponse::NoContent().finish());
|
||||
}
|
||||
|
||||
if let Ok(email_token) = EmailToken::get(&mut conn, me.uuid).await {
|
||||
if Utc::now().signed_duration_since(email_token.created_at) > Duration::hours(1) {
|
||||
email_token.delete(&mut conn).await?;
|
||||
} else {
|
||||
return Err(Error::TooManyRequests("Please allow 1 hour before sending a new email".to_string()))
|
||||
return Err(Error::TooManyRequests(
|
||||
"Please allow 1 hour before sending a new email".to_string(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use actix_web::{web, Scope};
|
||||
use actix_web::{Scope, web};
|
||||
|
||||
mod uuid;
|
||||
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
//! `/api/v1/channels/{uuid}/messages` Endpoints related to channel messages
|
||||
|
||||
use crate::{
|
||||
api::v1::auth::check_access_token, error::Error, structs::{Channel, Member}, utils::{get_auth_header, global_checks}, Data
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
structs::{Channel, Member},
|
||||
utils::{get_auth_header, global_checks},
|
||||
};
|
||||
use ::uuid::Uuid;
|
||||
use actix_web::{HttpRequest, HttpResponse, get, web};
|
||||
|
@ -14,11 +18,11 @@ struct MessageRequest {
|
|||
}
|
||||
|
||||
/// `GET /api/v1/channels/{uuid}/messages` Returns user with the given UUID
|
||||
///
|
||||
///
|
||||
/// requires auth: yes
|
||||
///
|
||||
///
|
||||
/// requires relation: yes
|
||||
///
|
||||
///
|
||||
/// ### Request Example
|
||||
/// ```
|
||||
/// json!({
|
||||
|
@ -26,7 +30,7 @@ struct MessageRequest {
|
|||
/// "offset": 0
|
||||
/// })
|
||||
/// ```
|
||||
///
|
||||
///
|
||||
/// ### Response Example
|
||||
/// ```
|
||||
/// json!({
|
||||
|
@ -42,7 +46,7 @@ struct MessageRequest {
|
|||
/// }
|
||||
/// });
|
||||
/// ```
|
||||
///
|
||||
///
|
||||
#[get("/{uuid}/messages")]
|
||||
pub async fn get(
|
||||
req: HttpRequest,
|
||||
|
|
|
@ -2,7 +2,11 @@ pub mod messages;
|
|||
pub mod socket;
|
||||
|
||||
use crate::{
|
||||
api::v1::auth::check_access_token, error::Error, structs::{Channel, Member}, utils::{get_auth_header, global_checks}, Data
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
structs::{Channel, Member},
|
||||
utils::{get_auth_header, global_checks},
|
||||
};
|
||||
use actix_web::{HttpRequest, HttpResponse, delete, get, web};
|
||||
use uuid::Uuid;
|
||||
|
|
|
@ -8,7 +8,10 @@ use futures_util::StreamExt as _;
|
|||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
api::v1::auth::check_access_token, structs::{Channel, Member}, utils::{get_ws_protocol_header, global_checks}, Data
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
structs::{Channel, Member},
|
||||
utils::{get_ws_protocol_header, global_checks},
|
||||
};
|
||||
|
||||
#[get("/{uuid}/socket")]
|
||||
|
@ -71,9 +74,7 @@ pub async fn ws(
|
|||
Ok(AggregatedMessage::Text(text)) => {
|
||||
let mut conn = data.cache_pool.get_multiplexed_tokio_connection().await?;
|
||||
|
||||
let message = channel
|
||||
.new_message(&data, uuid, text.to_string())
|
||||
.await?;
|
||||
let message = channel.new_message(&data, uuid, text.to_string()).await?;
|
||||
|
||||
redis::cmd("PUBLISH")
|
||||
.arg(&[channel_uuid.to_string(), serde_json::to_string(&message)?])
|
||||
|
|
|
@ -6,7 +6,11 @@ use serde::Deserialize;
|
|||
mod uuid;
|
||||
|
||||
use crate::{
|
||||
api::v1::auth::check_access_token, error::Error, structs::{Guild, StartAmountQuery}, utils::{get_auth_header, global_checks}, Data
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
structs::{Guild, StartAmountQuery},
|
||||
utils::{get_auth_header, global_checks},
|
||||
};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
@ -22,16 +26,16 @@ pub fn web() -> Scope {
|
|||
}
|
||||
|
||||
/// `POST /api/v1/guilds` Creates a new guild
|
||||
///
|
||||
///
|
||||
/// requires auth: yes
|
||||
///
|
||||
///
|
||||
/// ### Request Example
|
||||
/// ```
|
||||
/// json!({
|
||||
/// "name": "My new server!"
|
||||
/// });
|
||||
/// ```
|
||||
///
|
||||
///
|
||||
/// ### Response Example
|
||||
/// ```
|
||||
/// json!({
|
||||
|
@ -59,22 +63,17 @@ pub async fn post(
|
|||
|
||||
let uuid = check_access_token(auth_header, &mut conn).await?;
|
||||
|
||||
let guild = Guild::new(
|
||||
&mut conn,
|
||||
guild_info.name.clone(),
|
||||
uuid,
|
||||
)
|
||||
.await?;
|
||||
let guild = Guild::new(&mut conn, guild_info.name.clone(), uuid).await?;
|
||||
|
||||
Ok(HttpResponse::Ok().json(guild))
|
||||
}
|
||||
|
||||
/// `GET /api/v1/servers` Fetches all guilds
|
||||
///
|
||||
///
|
||||
/// requires auth: yes
|
||||
///
|
||||
///
|
||||
/// requires admin: yes
|
||||
///
|
||||
///
|
||||
/// ### Response Example
|
||||
/// ```
|
||||
/// json!([
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
use crate::{
|
||||
api::v1::auth::check_access_token, error::Error, structs::{Channel, Member}, utils::{get_auth_header, global_checks, order_by_is_above}, Data
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
structs::{Channel, Member},
|
||||
utils::{get_auth_header, global_checks, order_by_is_above},
|
||||
};
|
||||
use ::uuid::Uuid;
|
||||
use actix_web::{HttpRequest, HttpResponse, get, post, web};
|
||||
|
|
|
@ -5,13 +5,17 @@ use futures_util::StreamExt as _;
|
|||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
api::v1::auth::check_access_token, error::Error, structs::{Guild, Member}, utils::{get_auth_header, global_checks}, Data
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
structs::{Guild, Member},
|
||||
utils::{get_auth_header, global_checks},
|
||||
};
|
||||
|
||||
/// `PUT /api/v1/guilds/{uuid}/icon` Icon upload
|
||||
///
|
||||
///
|
||||
/// requires auth: no
|
||||
///
|
||||
///
|
||||
/// put request expects a file and nothing else
|
||||
#[put("{uuid}/icon")]
|
||||
pub async fn upload(
|
||||
|
|
|
@ -3,7 +3,11 @@ use serde::Deserialize;
|
|||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
api::v1::auth::check_access_token, error::Error, structs::{Guild, Member}, utils::{get_auth_header, global_checks}, Data
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
structs::{Guild, Member},
|
||||
utils::{get_auth_header, global_checks},
|
||||
};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
use crate::{
|
||||
api::v1::auth::check_access_token, error::Error, structs::Member, utils::{get_auth_header, global_checks}, Data
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
structs::Member,
|
||||
utils::{get_auth_header, global_checks},
|
||||
};
|
||||
use ::uuid::Uuid;
|
||||
use actix_web::{HttpRequest, HttpResponse, get, web};
|
||||
|
|
|
@ -6,11 +6,15 @@ use uuid::Uuid;
|
|||
mod channels;
|
||||
mod icon;
|
||||
mod invites;
|
||||
mod roles;
|
||||
mod members;
|
||||
mod roles;
|
||||
|
||||
use crate::{
|
||||
api::v1::auth::check_access_token, error::Error, structs::{Guild, Member}, utils::{get_auth_header, global_checks}, Data
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
structs::{Guild, Member},
|
||||
utils::{get_auth_header, global_checks},
|
||||
};
|
||||
|
||||
pub fn web() -> Scope {
|
||||
|
@ -34,9 +38,9 @@ pub fn web() -> Scope {
|
|||
}
|
||||
|
||||
/// `GET /api/v1/guilds/{uuid}` DESCRIPTION
|
||||
///
|
||||
///
|
||||
/// requires auth: yes
|
||||
///
|
||||
///
|
||||
/// ### Response Example
|
||||
/// ```
|
||||
/// json!({
|
||||
|
@ -65,7 +69,7 @@ pub fn web() -> Scope {
|
|||
/// ],
|
||||
/// "member_count": 20
|
||||
/// });
|
||||
/// ```
|
||||
/// ```
|
||||
#[get("/{uuid}")]
|
||||
pub async fn get(
|
||||
req: HttpRequest,
|
||||
|
|
|
@ -3,7 +3,11 @@ use actix_web::{HttpRequest, HttpResponse, get, post, web};
|
|||
use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
api::v1::auth::check_access_token, error::Error, structs::{Member, Role}, utils::{get_auth_header, global_checks, order_by_is_above}, Data
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
structs::{Member, Role},
|
||||
utils::{get_auth_header, global_checks, order_by_is_above},
|
||||
};
|
||||
|
||||
pub mod uuid;
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
use crate::{
|
||||
api::v1::auth::check_access_token, error::Error, structs::{Member, Role}, utils::{get_auth_header, global_checks}, Data
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
structs::{Member, Role},
|
||||
utils::{get_auth_header, global_checks},
|
||||
};
|
||||
use ::uuid::Uuid;
|
||||
use actix_web::{HttpRequest, HttpResponse, get, web};
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
use actix_web::{HttpRequest, HttpResponse, get, post, web};
|
||||
|
||||
use crate::{
|
||||
api::v1::auth::check_access_token, error::Error, structs::{Guild, Invite, Member}, utils::{get_auth_header, global_checks}, Data
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
structs::{Guild, Invite, Member},
|
||||
utils::{get_auth_header, global_checks},
|
||||
};
|
||||
|
||||
#[get("{id}")]
|
||||
pub async fn get(
|
||||
path: web::Path<(String,)>,
|
||||
data: web::Data<Data>,
|
||||
) -> Result<HttpResponse, Error> {
|
||||
pub async fn get(path: web::Path<(String,)>, data: web::Data<Data>) -> Result<HttpResponse, Error> {
|
||||
let mut conn = data.pool.get().await?;
|
||||
|
||||
let invite_id = path.into_inner().0;
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
//! `/api/v1/me/guilds` Contains endpoint related to guild memberships
|
||||
|
||||
use actix_web::{get, web, HttpRequest, HttpResponse};
|
||||
|
||||
use crate::{api::v1::auth::check_access_token, error::Error, structs::Me, utils::{get_auth_header, global_checks}, Data};
|
||||
use actix_web::{HttpRequest, HttpResponse, get, web};
|
||||
|
||||
use crate::{
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
structs::Me,
|
||||
utils::{get_auth_header, global_checks},
|
||||
};
|
||||
|
||||
/// `GET /api/v1/me/guilds` Returns all guild memberships in a list
|
||||
///
|
||||
///
|
||||
/// requires auth: yes
|
||||
///
|
||||
///
|
||||
/// ### Example Response
|
||||
/// ```
|
||||
/// json!([
|
||||
|
@ -44,4 +49,4 @@ pub async fn get(req: HttpRequest, data: web::Data<Data>) -> Result<HttpResponse
|
|||
let memberships = me.fetch_memberships(&data).await?;
|
||||
|
||||
Ok(HttpResponse::Ok().json(memberships))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,11 @@ use actix_web::{HttpRequest, HttpResponse, Scope, get, patch, web};
|
|||
use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
api::v1::auth::check_access_token, error::Error, structs::Me, utils::{get_auth_header, global_checks}, Data
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
structs::Me,
|
||||
utils::{get_auth_header, global_checks},
|
||||
};
|
||||
|
||||
mod guilds;
|
||||
|
@ -59,7 +63,13 @@ pub async fn update(
|
|||
|
||||
let uuid = check_access_token(auth_header, &mut conn).await?;
|
||||
|
||||
if form.avatar.is_some() || form.json.0.clone().is_some_and(|ni| ni.username.is_some() || ni.display_name.is_some()) {
|
||||
if form.avatar.is_some()
|
||||
|| form
|
||||
.json
|
||||
.0
|
||||
.clone()
|
||||
.is_some_and(|ni| ni.username.is_some() || ni.display_name.is_some())
|
||||
{
|
||||
global_checks(&data, uuid).await?;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@ use actix_web::{Scope, web};
|
|||
|
||||
mod auth;
|
||||
mod channels;
|
||||
mod invites;
|
||||
mod guilds;
|
||||
mod invites;
|
||||
mod me;
|
||||
mod stats;
|
||||
mod users;
|
||||
mod me;
|
||||
|
||||
pub fn web() -> Scope {
|
||||
web::scope("/v1")
|
||||
|
|
|
@ -25,9 +25,9 @@ struct Response {
|
|||
}
|
||||
|
||||
/// `GET /api/v1/` Returns stats about the server
|
||||
///
|
||||
///
|
||||
/// requires auth: no
|
||||
///
|
||||
///
|
||||
/// ### Response Example
|
||||
/// ```
|
||||
/// json!({
|
||||
|
|
|
@ -3,23 +3,25 @@
|
|||
use actix_web::{HttpRequest, HttpResponse, Scope, get, web};
|
||||
|
||||
use crate::{
|
||||
api::v1::auth::check_access_token, error::Error, structs::{StartAmountQuery, User}, utils::{get_auth_header, global_checks}, Data
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
structs::{StartAmountQuery, User},
|
||||
utils::{get_auth_header, global_checks},
|
||||
};
|
||||
|
||||
mod uuid;
|
||||
|
||||
pub fn web() -> Scope {
|
||||
web::scope("/users")
|
||||
.service(get)
|
||||
.service(uuid::get)
|
||||
web::scope("/users").service(get).service(uuid::get)
|
||||
}
|
||||
|
||||
/// `GET /api/v1/users` Returns all users on this instance
|
||||
///
|
||||
///
|
||||
/// requires auth: yes
|
||||
///
|
||||
///
|
||||
/// requires admin: yes
|
||||
///
|
||||
///
|
||||
/// ### Response Example
|
||||
/// ```
|
||||
/// json!([
|
||||
|
|
|
@ -4,15 +4,19 @@ use actix_web::{HttpRequest, HttpResponse, get, web};
|
|||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
api::v1::auth::check_access_token, error::Error, structs::User, utils::{get_auth_header, global_checks}, Data
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
structs::User,
|
||||
utils::{get_auth_header, global_checks},
|
||||
};
|
||||
|
||||
/// `GET /api/v1/users/{uuid}` Returns user with the given UUID
|
||||
///
|
||||
///
|
||||
/// requires auth: yes
|
||||
///
|
||||
///
|
||||
/// requires relation: yes
|
||||
///
|
||||
///
|
||||
/// ### Response Example
|
||||
/// ```
|
||||
/// json!({
|
||||
|
|
|
@ -12,9 +12,9 @@ struct Response {
|
|||
struct UnstableFeatures;
|
||||
|
||||
/// `GET /api/versions` Returns info about api versions.
|
||||
///
|
||||
///
|
||||
/// requires auth: no
|
||||
///
|
||||
///
|
||||
/// ### Response Example
|
||||
/// ```
|
||||
/// json!({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue