Restrict bots from creating servers, groups, acking messages, and making friends.
This commit is contained in:
@@ -9,6 +9,10 @@ use rocket::serde::json::Value;
|
||||
|
||||
#[put("/<username>/friend")]
|
||||
pub async fn req(user: User, username: String) -> Result<Value> {
|
||||
if user.bot.is_some() {
|
||||
return Err(Error::IsBot)
|
||||
}
|
||||
|
||||
let col = get_collection("users");
|
||||
let doc = col
|
||||
.find_one(
|
||||
|
||||
@@ -8,8 +8,11 @@ use rocket::serde::json::Value;
|
||||
|
||||
#[put("/<target>/block")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<Value> {
|
||||
let col = get_collection("users");
|
||||
if user.bot.is_some() {
|
||||
return Err(Error::IsBot)
|
||||
}
|
||||
|
||||
let col = get_collection("users");
|
||||
let target = target.fetch_user().await?;
|
||||
|
||||
match get_relationship(&user, &target.id) {
|
||||
|
||||
@@ -32,6 +32,10 @@ pub async fn req(
|
||||
data: Json<Data>,
|
||||
_ignore_id: String,
|
||||
) -> Result<()> {
|
||||
if user.bot.is_some() {
|
||||
return Err(Error::IsBot)
|
||||
}
|
||||
|
||||
data.validate()
|
||||
.map_err(|error| Error::FailedValidation { error })?;
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
use crate::database::*;
|
||||
use crate::util::result::Result;
|
||||
use crate::util::result::{Error, Result};
|
||||
|
||||
use rocket::serde::json::Value;
|
||||
|
||||
#[get("/<target>/relationship")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<Value> {
|
||||
if user.bot.is_some() {
|
||||
return Err(Error::IsBot)
|
||||
}
|
||||
|
||||
Ok(json!({ "status": get_relationship(&user, &target.id) }))
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
use crate::database::*;
|
||||
use crate::util::result::Result;
|
||||
use crate::util::result::{Error, Result};
|
||||
|
||||
use rocket::serde::json::Value;
|
||||
|
||||
#[get("/relationships")]
|
||||
pub async fn req(user: User) -> Result<Value> {
|
||||
if user.bot.is_some() {
|
||||
return Err(Error::IsBot)
|
||||
}
|
||||
|
||||
Ok(if let Some(vec) = user.relations {
|
||||
json!(vec)
|
||||
} else {
|
||||
|
||||
@@ -8,8 +8,11 @@ use rocket::serde::json::Value;
|
||||
|
||||
#[delete("/<target>/friend")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<Value> {
|
||||
let col = get_collection("users");
|
||||
if user.bot.is_some() {
|
||||
return Err(Error::IsBot)
|
||||
}
|
||||
|
||||
let col = get_collection("users");
|
||||
let target = target.fetch_user().await?;
|
||||
|
||||
match get_relationship(&user, &target.id) {
|
||||
|
||||
@@ -8,6 +8,10 @@ use rocket::serde::json::Value;
|
||||
|
||||
#[delete("/<target>/block")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<Value> {
|
||||
if user.bot.is_some() {
|
||||
return Err(Error::IsBot)
|
||||
}
|
||||
|
||||
let col = get_collection("users");
|
||||
let target = target.fetch_user().await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user