gourami

[UNMAINTAINED] Activitypub server in Rust
Log | Files | Refs | README | LICENSE

commit c37c975d999e15cf9f1090f10f3a9f45919b1fae
parent d51b641adc78ba12c391779d27a1c6b89bf698b5
Author: Alex Wennerberg <alex@alexwennerberg.com>
Date:   Sun, 24 May 2020 10:22:22 -0500

Merge pull request #16 from alexwennerberg/0.1.2

0.1.2
Diffstat:
ACHANGELOG | 8++++++++
MCargo.lock | 34+++++++++++++++++++++++++++++++++-
MCargo.toml | 3++-
MREADME.md | 2--
Mansible/playbook.yml | 4----
Msrc/ap.rs | 2+-
Msrc/lib.rs | 2+-
Msrc/main.rs | 10+++++++++-
8 files changed, 54 insertions(+), 11 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -0,0 +1,8 @@ +## 0.1.2 + +* Embed diesel migrations (#14) +* Fail gracefully on absent AP public key (#15) + +## 0.1.1 + +* First versioned release diff --git a/Cargo.lock b/Cargo.lock @@ -405,6 +405,16 @@ dependencies = [ ] [[package]] +name = "diesel_migrations" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf3cde8413353dc7f5d72fa8ce0b99a560a359d2c5ef1e5817ca731cd9008f4c" +dependencies = [ + "migrations_internals", + "migrations_macros", +] + +[[package]] name = "digest" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -639,7 +649,7 @@ dependencies = [ [[package]] name = "gourami_social" -version = "0.1.0" +version = "0.1.1" dependencies = [ "activitystreams", "ammonia", @@ -649,6 +659,7 @@ dependencies = [ "chrono", "clap", "diesel", + "diesel_migrations", "dotenv", "env_logger", "http-signature-normalization", @@ -1008,6 +1019,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" [[package]] +name = "migrations_internals" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b4fc84e4af020b837029e017966f86a1c2d5e83e64b589963d5047525995860" +dependencies = [ + "diesel", +] + +[[package]] +name = "migrations_macros" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9753f12909fd8d923f75ae5c3258cae1ed3c8ec052e1b38c93c21a6d157f789c" +dependencies = [ + "migrations_internals", + "proc-macro2 1.0.12", + "quote 1.0.5", + "syn 1.0.21", +] + +[[package]] name = "mime" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gourami_social" -version = "0.1.1" +version = "0.1.2" authors = ["alex wennerberg <alex@alexwennerberg.com>"] edition = "2018" @@ -13,6 +13,7 @@ bcrypt = "0.7.0" chrono = {version="0.4.11", features=["serde"]} clap = "2.33.0" diesel = { version = "1.4.4", features = ["sqlite", "chrono", "r2d2"] } +diesel_migrations = "1.4.0" dotenv = "0.15.0" env_logger = "0.7.1" http-signature-normalization = "0.5.1" diff --git a/README.md b/README.md @@ -39,8 +39,6 @@ Run `cargo install --path .` Configuration is done via [dotenv](https://github.com/dotenv-rs/dotenv). For development and testing, the `sample_env` file is good to get started -- copy it to `.env` in the same directory that you're running gourami. -Setup the database with diesel cli -- `cargo install diesel_cli --no-default-features --features "sqlite"` and `diesel setup`, or just run all of the `up.sql` scripts in the `migrations/` folder. - Run the local server with `gourami_social run` To create a user account: diff --git a/ansible/playbook.yml b/ansible/playbook.yml @@ -21,10 +21,6 @@ copy: src: ../static dest: /home/gourami - - name: copy migrations over - copy: - src: ../migrations - dest: /home/gourami - name: copy env over copy: src: prod_dotenv # distinguish dev/prod diff --git a/src/ap.rs b/src/ap.rs @@ -42,7 +42,7 @@ lazy_static! { domain: env::var("GOURAMI_DOMAIN").unwrap(), key_id: format!("{}#key", domain_url()), inbox: format!("{}/inbox", domain_url()), - public_key: std::fs::read_to_string(env::var("SIGNATURE_PUBKEY_PEM").unwrap()).unwrap() + public_key: std::fs::read_to_string(env::var("SIGNATURE_PUBKEY_PEM").unwrap()).unwrap_or("".to_owned()), }; } diff --git a/src/lib.rs b/src/lib.rs @@ -21,7 +21,7 @@ use warp::redirect::redirect; use warp::{Filter, Rejection, Reply}; use askama::Template; -use db::conn::POOL; +pub use db::conn::POOL; use db::note; use db::note::{Note, NoteInput}; use db::notification::{NewNotification, NewNotificationViewer, Notification, NotificationViewer}; diff --git a/src/main.rs b/src/main.rs @@ -1,14 +1,22 @@ use clap::{App, Arg, SubCommand}; use dotenv; use gourami_social::ap; +use gourami_social::POOL; use gourami_social::routes::run_server; +#[macro_use] +extern crate diesel_migrations; + +embed_migrations!("./migrations"); + #[tokio::main] async fn main() { dotenv::dotenv().ok(); env_logger::init(); + let conn = &POOL.get().unwrap(); + embedded_migrations::run(conn).unwrap(); let matches = App::new("Gourami") - .version("0.1.1") + .version("0.1.2") .author("Alex Wennerberg <alex@alexwennerberg.com>") .about("Gourami server and admin tools") .subcommand(App::new("run").about("Run server"))