Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

Commit

Permalink
review notes
Browse files Browse the repository at this point in the history
  • Loading branch information
darcys22 committed Oct 19, 2021
1 parent 32ea64e commit b3528c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
9 changes: 2 additions & 7 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,10 +626,7 @@ pub fn insert_message(
signature: &[u8],
) -> Result<Response, Rejection> {
let mut conn = storage::get_conn()?;
let message = match insert_message_impl(&mut conn, room, user, data, signature) {
Ok(m) => m,
Err(e) => return Err(e),
};
let message = insert_message_impl(&mut conn, room, user, data, signature)?;
let response = json!({ "status_code": StatusCode::OK.as_u16(), "message": message });
Ok(warp::reply::json(&response).into_response())
}
Expand Down Expand Up @@ -1231,9 +1228,7 @@ pub fn pin_message_impl(
room,
AuthorizationRequired { moderator: true, ..Default::default() },
)?;
if let Err(err) = delete_pinned_message_impl(conn, user, room) {
return Err(err);
};
let _ = delete_pinned_message_impl(conn, user, room)?;

let tx = conn.transaction().map_err(|_| Error::DatabaseFailedInternally)?;
let pinned_message = match tx
Expand Down
6 changes: 3 additions & 3 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ async fn test_pinned_messages() {
assert!(pinned_message.is_err());

//insert a message into the room
let data = "test message".as_bytes();
let signature = "test signature".as_bytes();
let data = b"test message";
let signature = b"test signature";

let message_id = handlers::insert_message_impl(&mut conn, &room, &user, &data, &signature)
let message_id = handlers::insert_message_impl(&mut conn, &room, &user, data, signature)
.unwrap()
.server_id;

Expand Down

0 comments on commit b3528c2

Please sign in to comment.