forked from jmug/stoatchat
feat(bots): implement bot routes
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
use revolt_quark::Result;
|
||||
|
||||
use serde_json::Value;
|
||||
use revolt_quark::{
|
||||
models::{Bot, User},
|
||||
Db, Error, Result,
|
||||
};
|
||||
use rocket::serde::json::Json;
|
||||
|
||||
#[get("/@me")]
|
||||
pub async fn fetch_owned_bots(/*user: UserRef*/) -> Result<Value> {
|
||||
todo!()
|
||||
pub async fn fetch_owned_bots(db: &Db, user: User) -> Result<Json<Vec<Bot>>> {
|
||||
if user.bot.is_some() {
|
||||
return Err(Error::IsBot);
|
||||
}
|
||||
|
||||
db.fetch_bots_by_user(&user.id).await.map(Json)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user