fix issue with adding new messages into DB
This commit is contained in:
parent
0572d90dc8
commit
8fee7ce9cc
|
@ -85,6 +85,13 @@ pub fn send_message(
|
||||||
conn: &Connection,
|
conn: &Connection,
|
||||||
server_sender: SP,
|
server_sender: SP,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
log::debug!("CUM CUM");
|
||||||
|
log::debug!("CUM CUM");
|
||||||
|
log::debug!("CUM CUM");
|
||||||
|
log::debug!("CUM CUM");
|
||||||
|
log::debug!("CUM CUM");
|
||||||
|
log::debug!("CUM CUM");
|
||||||
|
log::debug!("CUM CUM");
|
||||||
if let Ok(user_data) = db::users::get_user_by_id(user_id, conn) {
|
if let Ok(user_data) = db::users::get_user_by_id(user_id, conn) {
|
||||||
// Add message to DB
|
// Add message to DB
|
||||||
let key = user_data.insert_key;
|
let key = user_data.insert_key;
|
||||||
|
@ -95,7 +102,7 @@ pub fn send_message(
|
||||||
date: chrono::offset::Local::now(),
|
date: chrono::offset::Local::now(),
|
||||||
user_id: Id(uuid::Uuid::parse_str(identifier).expect("failed to parse user ID")),
|
user_id: Id(uuid::Uuid::parse_str(identifier).expect("failed to parse user ID")),
|
||||||
message: message.clone(),
|
message: message.clone(),
|
||||||
from_me: false,
|
from_me: true,
|
||||||
};
|
};
|
||||||
let _ = db::messages::add_my_message(db_message, conn).unwrap();
|
let _ = db::messages::add_my_message(db_message, conn).unwrap();
|
||||||
let fcp_req: String =
|
let fcp_req: String =
|
||||||
|
|
|
@ -2,6 +2,7 @@ use super::serv_handler::to_server_sender;
|
||||||
use crate::chat::types::{PackedMessage, RP, SP};
|
use crate::chat::types::{PackedMessage, RP, SP};
|
||||||
use async_std::task;
|
use async_std::task;
|
||||||
use fcpv2::types::traits::FcpParser;
|
use fcpv2::types::traits::FcpParser;
|
||||||
|
use regex::Regex;
|
||||||
use serde_derive::Deserialize;
|
use serde_derive::Deserialize;
|
||||||
use std::env;
|
use std::env;
|
||||||
use tokio::{
|
use tokio::{
|
||||||
|
@ -50,6 +51,12 @@ async fn server_responce_getter(mut receiver: OwnedReadHalf, client_sender: SP)
|
||||||
"SSKKeypair" => {
|
"SSKKeypair" => {
|
||||||
log::debug!("parsing keypair: {:?}", &req);
|
log::debug!("parsing keypair: {:?}", &req);
|
||||||
let keypair = fcpv2::types::SSKKeypair::parse(&received).unwrap();
|
let keypair = fcpv2::types::SSKKeypair::parse(&received).unwrap();
|
||||||
|
/*
|
||||||
|
let id_regex = Regex::new(r"^(\w*-\w*)").unwrap();
|
||||||
|
let identifier_type: String = id_regex
|
||||||
|
.captures(&keypair.identifier[..])
|
||||||
|
.expect("wrong type identifier")[0].to_string();
|
||||||
|
*/
|
||||||
match &keypair.identifier[..] {
|
match &keypair.identifier[..] {
|
||||||
"config-SSK" => {
|
"config-SSK" => {
|
||||||
log::debug!("got SSKKeypair: {:?}", &keypair);
|
log::debug!("got SSKKeypair: {:?}", &keypair);
|
||||||
|
@ -83,7 +90,9 @@ async fn server_responce_getter(mut receiver: OwnedReadHalf, client_sender: SP)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"DataFound" => {
|
||||||
|
},
|
||||||
_ => {
|
_ => {
|
||||||
log::debug!("unhandled: {}", &req);
|
log::debug!("unhandled: {}", &req);
|
||||||
client_sender
|
client_sender
|
||||||
|
|
Loading…
Reference in a new issue