jsonvalue-fix
This commit is contained in:
parent
c9650772bc
commit
a84bf61e4e
|
@ -12,7 +12,7 @@
|
|||
|
||||
### Как это работает
|
||||
|
||||
При каждом обращении к `/connect` создаётся отдельная на Redus PubSub каналы
|
||||
При каждом обращении к `/connect` создаётся отдельная асинхронная задача с подписками на Redus PubSub каналы
|
||||
- `new_reaction`
|
||||
- `new_shout`
|
||||
- `followers:<author_id>`
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use reqwest::header::{HeaderMap, HeaderValue, AUTHORIZATION, CONTENT_TYPE};
|
||||
use reqwest::Client as HTTPClient;
|
||||
use serde_json::json;
|
||||
use serde_json::{json, Value};
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::error::Error;
|
||||
|
@ -106,12 +106,12 @@ async fn get_shout_followers(shout_id: &str) -> Result<Vec<i32>, Box<dyn Error>>
|
|||
pub async fn is_fitting(
|
||||
listener_id: i32,
|
||||
kind: String,
|
||||
payload: HashMap<String, String>,
|
||||
payload: HashMap<String, Value>,
|
||||
) -> Result<bool, &'static str> {
|
||||
match &kind[0..9] {
|
||||
"new_react" => {
|
||||
// payload is Reaction, kind is new_reaction<reaction_kind>
|
||||
let shout_id = payload.get("shout").unwrap();
|
||||
let shout_id = payload.get("shout").unwrap().as_str().unwrap();
|
||||
let recipients = get_shout_followers(shout_id).await.unwrap();
|
||||
|
||||
Ok(recipients.contains(&listener_id))
|
||||
|
|
|
@ -4,6 +4,7 @@ use actix_web::{web, web::Bytes, App, HttpRequest, HttpResponse, HttpServer};
|
|||
use futures::StreamExt;
|
||||
use redis::{AsyncCommands, Client};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
@ -19,7 +20,7 @@ struct AppState {
|
|||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct RedisMessageData {
|
||||
payload: HashMap<String, String>,
|
||||
payload: HashMap<String, Value>,
|
||||
kind: String,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user