mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 05:26:59 +00:00
fix: delete bots; fetch public if owner
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -3098,7 +3098,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "revolt-quark"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/revoltchat/quark?rev=b1bc7eb0bab9f3cb3458fb4c8da4cb985177d2b2#b1bc7eb0bab9f3cb3458fb4c8da4cb985177d2b2"
|
||||
source = "git+https://github.com/revoltchat/quark?rev=1eb92e3b5893075de1c11332bab76bffd88d4fa8#1eb92e3b5893075de1c11332bab76bffd88d4fa8"
|
||||
dependencies = [
|
||||
"async-recursion",
|
||||
"async-std",
|
||||
|
||||
@@ -69,5 +69,5 @@ schemars = "0.8.8"
|
||||
rocket_okapi = { git = "https://github.com/insertish/okapi", rev = "dcf0df115596ee07a587a7a543cddf3d7944645b", features = [ "swagger" ] }
|
||||
|
||||
# quark
|
||||
revolt-quark = { git = "https://github.com/revoltchat/quark", rev = "b1bc7eb0bab9f3cb3458fb4c8da4cb985177d2b2" }
|
||||
revolt-quark = { git = "https://github.com/revoltchat/quark", rev = "1eb92e3b5893075de1c11332bab76bffd88d4fa8" }
|
||||
# revolt-quark = { path = "../quark" }
|
||||
|
||||
@@ -15,5 +15,5 @@ pub async fn delete_bot(db: &Db, user: User, target: Ref) -> Result<EmptyRespons
|
||||
return Err(Error::NotFound);
|
||||
}
|
||||
|
||||
db.delete_bot(&bot.id).await.map(|_| EmptyResponse)
|
||||
bot.delete(db).await.map(|_| EmptyResponse)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use revolt_quark::{models::File, Db, Error, Ref, Result};
|
||||
use revolt_quark::{
|
||||
models::{File, User},
|
||||
Db, Error, Ref, Result,
|
||||
};
|
||||
|
||||
use rocket::serde::json::Json;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -24,9 +27,9 @@ pub struct PublicBot {
|
||||
/// Fetch details of a public (or owned) bot by its id.
|
||||
#[openapi(tag = "Bots")]
|
||||
#[get("/<target>/invite")]
|
||||
pub async fn fetch_public_bot(db: &Db, target: Ref) -> Result<Json<PublicBot>> {
|
||||
pub async fn fetch_public_bot(db: &Db, user: Option<User>, target: Ref) -> Result<Json<PublicBot>> {
|
||||
let bot = target.as_bot(db).await?;
|
||||
if !bot.public {
|
||||
if !bot.public && user.map_or(true, |x| x.id != bot.owner) {
|
||||
return Err(Error::NotFound);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user