forked from jmug/stoatchat
Write out templates for routes.
This commit is contained in:
@@ -6,5 +6,5 @@ mod user;
|
||||
pub fn mount(rocket: Rocket) -> Rocket {
|
||||
rocket
|
||||
.mount("/api/account", routes![ account::create, account::verify_email, account::resend_email, account::login ])
|
||||
.mount("/api/users", routes![ user::me, user::lookup ])
|
||||
.mount("/api/users", routes![ user::me, user::dms, user::lookup ])
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use serde::{ Serialize, Deserialize };
|
||||
use mongodb::options::FindOptions;
|
||||
use bson::{ bson, doc };
|
||||
|
||||
/// retrieve your user information
|
||||
#[get("/@me")]
|
||||
pub fn me(user: User) -> JsonValue {
|
||||
let User ( id, username, doc ) = user;
|
||||
@@ -20,11 +21,19 @@ pub fn me(user: User) -> JsonValue {
|
||||
})
|
||||
}
|
||||
|
||||
/// retrieve another user's information
|
||||
#[get("/<id>")]
|
||||
pub fn user(user: User, id: String) -> JsonValue {
|
||||
json!([])
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Query {
|
||||
username: String,
|
||||
}
|
||||
|
||||
/// lookup a user on Revolt
|
||||
/// currently only supports exact username searches
|
||||
#[post("/lookup", data = "<query>")]
|
||||
pub fn lookup(_user: User, query: Json<Query>) -> JsonValue {
|
||||
let col = database::get_db().collection("users");
|
||||
@@ -47,3 +56,39 @@ pub fn lookup(_user: User, query: Json<Query>) -> JsonValue {
|
||||
|
||||
json!(results)
|
||||
}
|
||||
|
||||
/// retrieve all of your DMs
|
||||
#[get("/@me/dms")]
|
||||
pub fn dms(user: User) -> JsonValue {
|
||||
json!([])
|
||||
}
|
||||
|
||||
/// open a DM with a user
|
||||
#[get("/<id>/dm")]
|
||||
pub fn dm(user: User, id: String) -> JsonValue {
|
||||
json!([])
|
||||
}
|
||||
|
||||
/// retrieve all of your friends
|
||||
#[get("/@me/friend")]
|
||||
pub fn get_friends(user: User) -> JsonValue {
|
||||
json!([])
|
||||
}
|
||||
|
||||
/// retrieve friend status with user
|
||||
#[get("/<id>/friend")]
|
||||
pub fn get_friend(user: User, id: String) -> JsonValue {
|
||||
json!([])
|
||||
}
|
||||
|
||||
/// create or accept a friend request
|
||||
#[put("/<id>/friend")]
|
||||
pub fn add_friend(user: User, id: String) -> JsonValue {
|
||||
json!([])
|
||||
}
|
||||
|
||||
/// remove a friend or deny a request
|
||||
#[delete("/<id>/friend")]
|
||||
pub fn remove_friend(user: User, id: String) -> JsonValue {
|
||||
json!([])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user