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]]
|
||||
name = "discoursio-presence"
|
||||
version = "0.2.16"
|
||||
version = "0.2.19"
|
||||
dependencies = [
|
||||
"actix-web",
|
||||
"futures",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "discoursio-presence"
|
||||
version = "0.2.16"
|
||||
version = "0.2.19"
|
||||
edition = "2021"
|
||||
|
||||
# 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;
|
||||
|
||||
|
||||
async fn get_author_id(user: &str) -> Result<i32, Box<dyn Error>> {
|
||||
let api_base = env::var("API_BASE")?;
|
||||
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);
|
||||
Ok(id as i32)
|
||||
}
|
||||
None => {
|
||||
Err(Box::new(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
"No author ID found in the response",
|
||||
)))
|
||||
}
|
||||
None => Err(Box::new(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
"No author ID found in the response",
|
||||
))),
|
||||
}
|
||||
} else {
|
||||
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>> {
|
||||
let auth_api_base = env::var("AUTH_URL")?;
|
||||
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(|query| query.get("claims"))
|
||||
.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 {
|
||||
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());
|
||||
Err(Box::new(std::io::Error::new(
|
||||
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" {
|
||||
// payload is Shout
|
||||
|
||||
// TODO: check all community subscribers if no then
|
||||
// TODO: check all topics subscribers if no then
|
||||
// TODO: check all authors subscribers
|
||||
// TODO: check all shout.communities subscribers if no then
|
||||
// TODO: check all shout.topics subscribers if no then
|
||||
// TODO: check all shout.authors subscribers ???
|
||||
|
||||
Ok(true)
|
||||
} else if message_data.entity == "chat" {
|
||||
|
@ -186,7 +186,7 @@ pub async fn is_fitting(
|
|||
} else if message_data.entity == "follower" {
|
||||
// payload is Author
|
||||
Ok(true)
|
||||
}else {
|
||||
} else {
|
||||
eprintln!("[data] unknown entity");
|
||||
eprintln!("{:?}", message_data);
|
||||
Ok(false)
|
||||
|
|
Loading…
Reference in New Issue
Block a user