userid-trim-fix
This commit is contained in:
parent
5c6f27ba9f
commit
ffe18a89e5
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -455,7 +455,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "discoursio-presence"
|
name = "discoursio-presence"
|
||||||
version = "0.2.16"
|
version = "0.2.19"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-web",
|
"actix-web",
|
||||||
"futures",
|
"futures",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "discoursio-presence"
|
name = "discoursio-presence"
|
||||||
version = "0.2.16"
|
version = "0.2.19"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
28
src/data.rs
28
src/data.rs
|
@ -7,7 +7,6 @@ use std::error::Error;
|
||||||
|
|
||||||
use crate::SSEMessageData;
|
use crate::SSEMessageData;
|
||||||
|
|
||||||
|
|
||||||
async fn get_author_id(user: &str) -> Result<i32, Box<dyn Error>> {
|
async fn get_author_id(user: &str) -> Result<i32, Box<dyn Error>> {
|
||||||
let api_base = env::var("API_BASE")?;
|
let api_base = env::var("API_BASE")?;
|
||||||
let query_name = "get_author_id";
|
let query_name = "get_author_id";
|
||||||
|
@ -46,12 +45,10 @@ async fn get_author_id(user: &str) -> Result<i32, Box<dyn Error>> {
|
||||||
println!("Author ID retrieved: {}", id);
|
println!("Author ID retrieved: {}", id);
|
||||||
Ok(id as i32)
|
Ok(id as i32)
|
||||||
}
|
}
|
||||||
None => {
|
None => Err(Box::new(std::io::Error::new(
|
||||||
Err(Box::new(std::io::Error::new(
|
std::io::ErrorKind::Other,
|
||||||
std::io::ErrorKind::Other,
|
"No author ID found in the response",
|
||||||
"No author ID found in the response",
|
))),
|
||||||
)))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Err(Box::new(std::io::Error::new(
|
Err(Box::new(std::io::Error::new(
|
||||||
|
@ -61,7 +58,6 @@ async fn get_author_id(user: &str) -> Result<i32, Box<dyn Error>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub async fn get_id_by_token(token: &str) -> Result<i32, Box<dyn Error>> {
|
pub async fn get_id_by_token(token: &str) -> Result<i32, Box<dyn Error>> {
|
||||||
let auth_api_base = env::var("AUTH_URL")?;
|
let auth_api_base = env::var("AUTH_URL")?;
|
||||||
let query_name = "validate_jwt_token";
|
let query_name = "validate_jwt_token";
|
||||||
|
@ -97,7 +93,8 @@ pub async fn get_id_by_token(token: &str) -> Result<i32, Box<dyn Error>> {
|
||||||
.and_then(|data| data.get(query_name))
|
.and_then(|data| data.get(query_name))
|
||||||
.and_then(|query| query.get("claims"))
|
.and_then(|query| query.get("claims"))
|
||||||
.and_then(|claims| claims.get("sub"))
|
.and_then(|claims| claims.get("sub"))
|
||||||
.and_then(|id| id.as_str());
|
.and_then(|id| id.as_str())
|
||||||
|
.map(|id| id.trim());
|
||||||
|
|
||||||
match user_id {
|
match user_id {
|
||||||
Some(id) => {
|
Some(id) => {
|
||||||
|
@ -154,7 +151,10 @@ async fn get_shout_followers(shout_id: &str) -> Result<Vec<i32>, Box<dyn Error>>
|
||||||
println!("Request failed with status: {}", response.status());
|
println!("Request failed with status: {}", response.status());
|
||||||
Err(Box::new(std::io::Error::new(
|
Err(Box::new(std::io::Error::new(
|
||||||
std::io::ErrorKind::Other,
|
std::io::ErrorKind::Other,
|
||||||
format!("[get_shout_followers] Request failed with status: {}", response.status()),
|
format!(
|
||||||
|
"[get_shout_followers] Request failed with status: {}",
|
||||||
|
response.status()
|
||||||
|
),
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,9 +172,9 @@ pub async fn is_fitting(
|
||||||
} else if message_data.entity == "shout" {
|
} else if message_data.entity == "shout" {
|
||||||
// payload is Shout
|
// payload is Shout
|
||||||
|
|
||||||
// TODO: check all community subscribers if no then
|
// TODO: check all shout.communities subscribers if no then
|
||||||
// TODO: check all topics subscribers if no then
|
// TODO: check all shout.topics subscribers if no then
|
||||||
// TODO: check all authors subscribers
|
// TODO: check all shout.authors subscribers ???
|
||||||
|
|
||||||
Ok(true)
|
Ok(true)
|
||||||
} else if message_data.entity == "chat" {
|
} else if message_data.entity == "chat" {
|
||||||
|
@ -186,7 +186,7 @@ pub async fn is_fitting(
|
||||||
} else if message_data.entity == "follower" {
|
} else if message_data.entity == "follower" {
|
||||||
// payload is Author
|
// payload is Author
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}else {
|
} else {
|
||||||
eprintln!("[data] unknown entity");
|
eprintln!("[data] unknown entity");
|
||||||
eprintln!("{:?}", message_data);
|
eprintln!("{:?}", message_data);
|
||||||
Ok(false)
|
Ok(false)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user