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

Commit

Permalink
Merge branch 'main' into pinned-messages
Browse files Browse the repository at this point in the history
  • Loading branch information
darcys22 authored Sep 16, 2021
2 parents 875a2c0 + f13b903 commit ad9cb57
Show file tree
Hide file tree
Showing 7 changed files with 277 additions and 269 deletions.
14 changes: 10 additions & 4 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,24 @@ Make sure you're pointing to the right openssl installation (e.g. macOS provides

### Step 2: Build the project

The Linux Rust installer assumes that you already have a C linker installed. If this is not the case you'll see `error: linker 'cc' not found`. To fix this, run:

```
cargo build --release
sudo apt update
sudo apt upgrade
sudo apt install build-essential libssl-dev pkg-config
```

The Linux Rust installer assumes that you already have a C linker installed. If this is not the case you'll see `error: linker 'cc' not found`. To fix this, run:
(Or the equivalent on a non-Debian-based Linux system).

Build it with

```
apt update
sudo apt install build-essential
cargo build --release
```

### Step 3: Run it
The two files generated in step 1 should be copied to the same directory as the executable. Alternatively you can use the command line arguments below to specify their locations. The executable needs both the x25519-public-key and the x25519-private-key to run.

```
./target/release/session-open-group-server
Expand Down
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "session-open-group-server"
version = "0.1.8"
version = "0.1.9"
authors = ["Niels Andriesse <niels@oxen.io>"]
edition = "2018"
description = "The Session open group server. Use this to run a custom open group."
Expand All @@ -27,6 +27,7 @@ log4rs = "1.0"
octocrab = "0.9"
rand = "0.8"
rand_core = "0.5"
regex = "1"
reqwest = { version = "0.11", features = ["json"] }
rusqlite = { version = "0.24", features = ["bundled"] }
rusqlite_migration = "0.4"
Expand Down
156 changes: 68 additions & 88 deletions src/handlers.rs

Large diffs are not rendered by default.

18 changes: 7 additions & 11 deletions src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ pub async fn handle_rpc_call(rpc_call: RpcCall) -> Result<Response, Rejection> {
// Get the auth token if possible
let auth_token = get_auth_token(&rpc_call);
// Get the room ID
let room_id = get_room_id(&rpc_call);
let room_id_str = get_room_id(&rpc_call);
// Switch on the HTTP method
match rpc_call.method.as_ref() {
"GET" => {
return handle_get_request(room_id, rpc_call, &path, auth_token, query_params).await
return handle_get_request(room_id_str, rpc_call, &path, auth_token, query_params).await
}
"POST" => return handle_post_request(room_id, rpc_call, &path, auth_token).await,
"POST" => return handle_post_request(room_id_str, rpc_call, &path, auth_token).await,
"DELETE" => {
let pool = get_pool_for_room(&rpc_call)?;
return handle_delete_request(rpc_call, &path, auth_token, &pool).await;
Expand Down Expand Up @@ -439,14 +439,10 @@ async fn handle_delete_request(
// Utilities

fn get_pool_for_room(rpc_call: &RpcCall) -> Result<storage::DatabaseConnectionPool, Rejection> {
let room_id = match get_room_id(&rpc_call) {
Some(room_id) => room_id,
None => {
warn!("Missing room ID.");
return Err(warp::reject::custom(Error::InvalidRpcCall));
}
};
return Ok(storage::pool_by_room_id(&room_id));
let room_id = get_room_id(&rpc_call).ok_or(Error::ValidationFailed)?;
return Ok(storage::pool_by_room_id(
&storage::RoomId::new(&room_id).ok_or(Error::ValidationFailed)?,
));
}

fn get_auth_token(rpc_call: &RpcCall) -> Option<String> {
Expand Down
Loading

0 comments on commit ad9cb57

Please sign in to comment.