mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 13:36:59 +00:00
Update CORS options.
Disallow bots to be added as friends.
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
export version=0.5.2-alpha.0
|
||||
export version=0.5.2-alpha.1
|
||||
echo "pub const VERSION: &str = \"${version}\";" > src/version.rs
|
||||
|
||||
15
src/main.rs
15
src/main.rs
@@ -29,6 +29,7 @@ use rauth::{
|
||||
auth::Auth,
|
||||
options::{Template, Templates},
|
||||
};
|
||||
use std::str::FromStr;
|
||||
use rocket_cors::AllowedOrigins;
|
||||
use rocket::catchers;
|
||||
use util::variables::{
|
||||
@@ -69,6 +70,20 @@ async fn main() {
|
||||
async fn launch_web() {
|
||||
let cors = rocket_cors::CorsOptions {
|
||||
allowed_origins: AllowedOrigins::All,
|
||||
allowed_methods: [
|
||||
"Get",
|
||||
"Put",
|
||||
"Post",
|
||||
"Delete",
|
||||
"Options",
|
||||
"Head",
|
||||
"Trace",
|
||||
"Connect",
|
||||
"Patch",
|
||||
]
|
||||
.iter()
|
||||
.map(|s| FromStr::from_str(s).unwrap())
|
||||
.collect(),
|
||||
..Default::default()
|
||||
}
|
||||
.to_cors()
|
||||
|
||||
@@ -36,6 +36,9 @@ pub async fn req(user: User, username: String) -> Result<Value> {
|
||||
})?;
|
||||
|
||||
let target_user = Ref::from(target_id.to_string())?.fetch_user().await?;
|
||||
if target_user.bot.is_some() {
|
||||
return Err(Error::IsBot)
|
||||
}
|
||||
|
||||
match get_relationship(&user, &target_id) {
|
||||
RelationshipStatus::User => return Err(Error::NoEffect),
|
||||
|
||||
@@ -1 +1 @@
|
||||
pub const VERSION: &str = "0.5.2-alpha.0";
|
||||
pub const VERSION: &str = "0.5.2-alpha.1";
|
||||
|
||||
Reference in New Issue
Block a user