gourami

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

commit 98110e30bde49bc48f3245a6e18262b86d282c24
parent 25cd9034950236d3ec30120bd2decd6c9db2ec2e
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sun,  3 May 2020 11:01:13 -0500

Rustfmt and some cargo cleanup

Diffstat:
Msrc/ap.rs | 8++------
Msrc/db/note.rs | 13++++++-------
Msrc/db/notification.rs | 2+-
Msrc/lib.rs | 22++++++++++++----------
4 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/src/ap.rs b/src/ap.rs @@ -21,12 +21,8 @@ lazy_static! { } // ActivityPub outbox -fn send_to_outbox(activity: bool) { // activitystreams object - // fetch/store from db. - // db objects need to serialize/deserialize this object - // if get -> fetch from db - // if post -> put to db, send to inbox of followers - // send to inbox of followers +fn send_to_outbox(activity: bool) { + // activitystreams object fetch/store from db. db objects need to serialize/deserialize this object if get -> fetch from db if post -> put to db, send to inbox of followers send to inbox of followers } enum Action { diff --git a/src/db/note.rs b/src/db/note.rs @@ -3,8 +3,7 @@ use crate::db::user::User; use ammonia; use maplit::hashset; use regex::Regex; -use serde::{de::Error, Deserialize, Deserializer, Serialize}; -use std::env; // weird import +use serde::{Deserialize, Serialize}; /// This isn't queryable directly, /// It only works when joined with the users table @@ -26,11 +25,11 @@ pub struct Note { pub remote_id: Option<String>, } -impl Note { - fn get_url(&self) -> String { - format!("{}/note/{}", env::var("GOURAMI_DOMAIN").unwrap(), self.id) - } -} +// impl Note { +// fn get_url(&self) -> String { +// format!("{}/note/{}", env::var("GOURAMI_DOMAIN").unwrap(), self.id) +// } +// } /// Content in the DB is stored in plaintext (WILL BE) /// We want to render it so that it is rendered in HTML diff --git a/src/db/notification.rs b/src/db/notification.rs @@ -1,5 +1,5 @@ use super::schema::{notification_viewers, notifications}; -use serde::{de::Error, Deserialize, Deserializer, Serialize}; +use serde::{Deserialize, Serialize}; #[derive(Queryable, Clone, Deserialize, Serialize)] pub struct Notification { diff --git a/src/lib.rs b/src/lib.rs @@ -1,11 +1,13 @@ +// on for development work +#![allow(dead_code)] +#![allow(unused_imports)] + #[macro_use] extern crate diesel; #[macro_use] extern crate log; #[macro_use] extern crate lazy_static; -#[macro_use] -extern crate maplit; use serde_json::Value; use std::convert::Infallible; @@ -15,7 +17,7 @@ use warp::filters::path::FullPath; use warp::http; use warp::hyper::Body; use warp::redirect::redirect; -use warp::{reject::Reject, Filter, Rejection, Reply}; +use warp::{Filter, Rejection, Reply}; use askama::Template; use db::conn::POOL; @@ -406,9 +408,9 @@ fn do_login(form: LoginForm) -> impl Reply { } } -fn do_logout(cookie: String) -> impl Reply { +fn do_logout(cook: String) -> impl Reply { use db::schema::sessions::dsl::*; - diesel::delete(sessions.filter(cookie.eq(cookie))) + diesel::delete(sessions.filter(cookie.eq(cook))) .execute(&POOL.get().unwrap()) .unwrap(); redirect(warp::http::Uri::from_static("/")) @@ -459,7 +461,7 @@ fn get_single_note(note_id: i32) -> Option<Vec<UserNote>> { Some( results .into_iter() - .map(|mut a| { + .map(|a| { // the ids are swapped for some reason UserNote { note: a.0, @@ -663,13 +665,13 @@ fn render_user_edit_page(user: Option<User>, user_name: String) -> impl Reply { pub fn get_outbox() {} -pub fn post_outbox(message: Value) {} +// pub fn post_outbox(message: Value) {} // TODO figure out how to follow mastodon // -pub fn user_followers(user_name: String) {} +// pub fn user_followers(user_name: String) {} -pub fn user_following(user_name: String) {} +// pub fn user_following(user_name: String) {} pub fn post_inbox(message: Value) -> impl Reply { // TODO check if it is a create note message @@ -699,7 +701,7 @@ fn edit_user(user: Option<User>, user_name: String, f: EditForm) -> impl Reply { redirect(red) } -async fn handle_rejection(err: Rejection) -> Result<impl Reply, Infallible> { +async fn handle_rejection(_: Rejection) -> Result<impl Reply, Infallible> { Ok(render_template(&ErrorTemplate { global: Global::create(None, "error"), error_message: