jsonvalue-fix
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user