forked from jmug/stoatchat
Update CORS options.
Disallow bots to be added as friends.
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/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
|
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,
|
auth::Auth,
|
||||||
options::{Template, Templates},
|
options::{Template, Templates},
|
||||||
};
|
};
|
||||||
|
use std::str::FromStr;
|
||||||
use rocket_cors::AllowedOrigins;
|
use rocket_cors::AllowedOrigins;
|
||||||
use rocket::catchers;
|
use rocket::catchers;
|
||||||
use util::variables::{
|
use util::variables::{
|
||||||
@@ -69,6 +70,20 @@ async fn main() {
|
|||||||
async fn launch_web() {
|
async fn launch_web() {
|
||||||
let cors = rocket_cors::CorsOptions {
|
let cors = rocket_cors::CorsOptions {
|
||||||
allowed_origins: AllowedOrigins::All,
|
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()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.to_cors()
|
.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?;
|
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) {
|
match get_relationship(&user, &target_id) {
|
||||||
RelationshipStatus::User => return Err(Error::NoEffect),
|
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