Include sender in message model
This commit is contained in:
parent
b5eb1d1113
commit
86c9a53a1a
|
@ -298,13 +298,13 @@ pub async fn get_messages(query_params: HashMap<String, String>, pool: &storage:
|
|||
// Query the database
|
||||
let raw_query: String;
|
||||
if query_params.get("from_server_id").is_some() {
|
||||
raw_query = format!("SELECT id, data, signature FROM {} WHERE rowid > (?1) LIMIT (?2)", storage::MESSAGES_TABLE);
|
||||
raw_query = format!("SELECT id, public_key, data, signature FROM {} WHERE rowid > (?1) LIMIT (?2)", storage::MESSAGES_TABLE);
|
||||
} else {
|
||||
raw_query = format!("SELECT id, data, signature FROM {} ORDER BY rowid DESC LIMIT (?2)", storage::MESSAGES_TABLE);
|
||||
raw_query = format!("SELECT id, public_key, data, signature FROM {} ORDER BY rowid DESC LIMIT (?2)", storage::MESSAGES_TABLE);
|
||||
}
|
||||
let mut query = conn.prepare(&raw_query).map_err(|_| Error::DatabaseFailedInternally)?;
|
||||
let rows = match query.query_map(params![ from_server_id, limit ], |row| {
|
||||
Ok(models::Message { server_id : row.get(0)?, data : row.get(1)?, signature : row.get(2)? })
|
||||
Ok(models::Message { server_id : row.get(0)?, public_key : row.get(1)?, data : row.get(2)?, signature : row.get(3)? })
|
||||
}) {
|
||||
Ok(rows) => rows,
|
||||
Err(e) => {
|
||||
|
|
|
@ -3,6 +3,7 @@ use serde::{Deserialize, Serialize};
|
|||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct Message {
|
||||
pub server_id: Option<i64>,
|
||||
pub public_key: Option<String>,
|
||||
pub data: String,
|
||||
pub signature: String
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ pub async fn handle_rpc_call(rpc_call: RpcCall) -> Result<Response, Rejection> {
|
|||
let pool = storage::pool_by_room_id(&room_id);
|
||||
// Check that the endpoint is a valid URI and deconstruct it into a path
|
||||
// and query parameters.
|
||||
// Adding "http://placeholder.io" in front of the endpoint we get is a workaround
|
||||
// Adding "http://placeholder.io" in front of the endpoint is a workaround
|
||||
// for the fact that the URL crate doesn't accept relative URLs. There are
|
||||
// other (cleaner) ways to fix this but they tend to be much more complex.
|
||||
let raw_uri = format!("http://placeholder.io/{}", rpc_call.endpoint.trim_start_matches("/"));
|
||||
|
|
Loading…
Reference in New Issue