RUN mkdir -p ./src/bin \
&& echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs
RUN cargo build --release --bin lemmy
-RUN rm -r ./target/release/.fingerprint/server-*
+RUN rm -r ./target/release/.fingerprint/lemmy_server-*
# copy your source tree
# RUN rm -rf ./src/
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+[[package]]
+name = "lemmy_server"
+version = "0.0.1"
+dependencies = [
+ "activitypub 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "actix 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "actix-web 0.7.18 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bcrypt 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "diesel 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "diesel_migrations 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "dotenv 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "jsonwebtoken 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)",
+ "strum 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "strum_macros 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "libc"
version = "0.2.49"
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
-[[package]]
-name = "server"
-version = "0.0.1"
-dependencies = [
- "activitypub 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "actix 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "actix-web 0.7.18 (registry+https://github.com/rust-lang/crates.io-index)",
- "bcrypt 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "diesel 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "diesel_migrations 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "dotenv 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "jsonwebtoken 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)",
- "strum 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "strum_macros 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
[[package]]
name = "sha1"
version = "0.6.0"
[package]
-name = "server"
+name = "lemmy_server"
version = "0.0.1"
authors = ["Dessalines <happydooby@gmail.com>"]
-autobins = false
-
-[[bin]]
-name = "lemmy"
-path = "src/bin/main.rs"
[dependencies]
diesel = { version = "1.4.2", features = ["postgres","chrono"] }
extern crate activitypub;
use self::activitypub::{context, actor::Person};
-use actions::user::User_;
+use db::user::User_;
impl User_ {
pub fn person(&self) -> Person {
use diesel::result::Error;
use serde::{Deserialize, Serialize};
use {Crud, Likeable, Saveable};
-use actions::post::Post;
+use super::post::Post;
// WITH RECURSIVE MyTree AS (
// SELECT * FROM comment WHERE parent_id IS NULL
mod tests {
use establish_connection;
use super::*;
- use actions::post::*;
- use actions::community::*;
- use actions::user::*;
+ use super::super::post::*;
+ use super::super::community::*;
+ use super::super::user::*;
use Crud;
#[test]
fn test_crud() {
page: Option<i64>,
limit: Option<i64>,
) -> Result<Vec<Self>, Error> {
- use actions::comment_view::comment_view::dsl::*;
+ use super::comment_view::comment_view::dsl::*;
let (limit, offset) = limit_and_offset(page, limit);
}
pub fn read(conn: &PgConnection, from_comment_id: i32, my_user_id: Option<i32>) -> Result<Self, Error> {
- use actions::comment_view::comment_view::dsl::*;
+ use super::comment_view::comment_view::dsl::*;
let mut query = comment_view.into_boxed();
page: Option<i64>,
limit: Option<i64>,
) -> Result<Vec<Self>, Error> {
- use actions::comment_view::reply_view::dsl::*;
+ use super::comment_view::reply_view::dsl::*;
let (limit, offset) = limit_and_offset(page, limit);
mod tests {
use establish_connection;
use super::*;
- use actions::post::*;
- use actions::community::*;
- use actions::user::*;
- use actions::comment::*;
+ use super::super::post::*;
+ use super::super::community::*;
+ use super::super::user::*;
+ use super::super::comment::*;
use {Crud,Likeable};
#[test]
fn test_crud() {
mod tests {
use establish_connection;
use super::*;
- use actions::user::*;
+ use super::super::user::*;
use Crud;
#[test]
fn test_crud() {
impl CommunityView {
pub fn read(conn: &PgConnection, from_community_id: i32, from_user_id: Option<i32>) -> Result<Self, Error> {
- use actions::community_view::community_view::dsl::*;
+ use super::community_view::community_view::dsl::*;
let mut query = community_view.into_boxed();
page: Option<i64>,
limit: Option<i64>,
) -> Result<Vec<Self>, Error> {
- use actions::community_view::community_view::dsl::*;
+ use super::community_view::community_view::dsl::*;
let mut query = community_view.into_boxed();
let (limit, offset) = limit_and_offset(page, limit);
impl CommunityModeratorView {
pub fn for_community(conn: &PgConnection, from_community_id: i32) -> Result<Vec<Self>, Error> {
- use actions::community_view::community_moderator_view::dsl::*;
+ use super::community_view::community_moderator_view::dsl::*;
community_moderator_view.filter(community_id.eq(from_community_id)).load::<Self>(conn)
}
pub fn for_user(conn: &PgConnection, from_user_id: i32) -> Result<Vec<Self>, Error> {
- use actions::community_view::community_moderator_view::dsl::*;
+ use super::community_view::community_moderator_view::dsl::*;
community_moderator_view.filter(user_id.eq(from_user_id)).load::<Self>(conn)
}
}
impl CommunityFollowerView {
pub fn for_community(conn: &PgConnection, from_community_id: i32) -> Result<Vec<Self>, Error> {
- use actions::community_view::community_follower_view::dsl::*;
+ use super::community_view::community_follower_view::dsl::*;
community_follower_view.filter(community_id.eq(from_community_id)).load::<Self>(conn)
}
pub fn for_user(conn: &PgConnection, from_user_id: i32) -> Result<Vec<Self>, Error> {
- use actions::community_view::community_follower_view::dsl::*;
+ use super::community_view::community_follower_view::dsl::*;
community_follower_view.filter(user_id.eq(from_user_id)).load::<Self>(conn)
}
}
impl CommunityUserBanView {
pub fn for_community(conn: &PgConnection, from_community_id: i32) -> Result<Vec<Self>, Error> {
- use actions::community_view::community_user_ban_view::dsl::*;
+ use super::community_view::community_user_ban_view::dsl::*;
community_user_ban_view.filter(community_id.eq(from_community_id)).load::<Self>(conn)
}
pub fn for_user(conn: &PgConnection, from_user_id: i32) -> Result<Vec<Self>, Error> {
- use actions::community_view::community_user_ban_view::dsl::*;
+ use super::community_view::community_user_ban_view::dsl::*;
community_user_ban_view.filter(user_id.eq(from_user_id)).load::<Self>(conn)
}
pub fn get(conn: &PgConnection, from_user_id: i32, from_community_id: i32) -> Result<Self, Error> {
- use actions::community_view::community_user_ban_view::dsl::*;
+ use super::community_view::community_user_ban_view::dsl::*;
community_user_ban_view
.filter(user_id.eq(from_user_id))
.filter(community_id.eq(from_community_id))
impl SiteView {
pub fn read(conn: &PgConnection) -> Result<Self, Error> {
- use actions::community_view::site_view::dsl::*;
+ use super::community_view::site_view::dsl::*;
site_view.first::<Self>(conn)
}
}
mod tests {
use establish_connection;
use super::*;
- use actions::user::*;
- use actions::post::*;
- use actions::community::*;
- use actions::comment::*;
+ use super::super::user::*;
+ use super::super::post::*;
+ use super::super::community::*;
+ use super::super::comment::*;
// use Crud;
#[test]
fn test_crud() {
page: Option<i64>,
limit: Option<i64>,
) -> Result<Vec<Self>, Error> {
- use actions::moderator_views::mod_remove_post_view::dsl::*;
+ use super::moderator_views::mod_remove_post_view::dsl::*;
let mut query = mod_remove_post_view.into_boxed();
let (limit, offset) = limit_and_offset(page, limit);
page: Option<i64>,
limit: Option<i64>,
) -> Result<Vec<Self>, Error> {
- use actions::moderator_views::mod_lock_post_view::dsl::*;
+ use super::moderator_views::mod_lock_post_view::dsl::*;
let mut query = mod_lock_post_view.into_boxed();
let (limit, offset) = limit_and_offset(page, limit);
page: Option<i64>,
limit: Option<i64>,
) -> Result<Vec<Self>, Error> {
- use actions::moderator_views::mod_remove_comment_view::dsl::*;
+ use super::moderator_views::mod_remove_comment_view::dsl::*;
let mut query = mod_remove_comment_view.into_boxed();
let (limit, offset) = limit_and_offset(page, limit);
page: Option<i64>,
limit: Option<i64>,
) -> Result<Vec<Self>, Error> {
- use actions::moderator_views::mod_remove_community_view::dsl::*;
+ use super::moderator_views::mod_remove_community_view::dsl::*;
let mut query = mod_remove_community_view.into_boxed();
let (limit, offset) = limit_and_offset(page, limit);
page: Option<i64>,
limit: Option<i64>,
) -> Result<Vec<Self>, Error> {
- use actions::moderator_views::mod_ban_from_community_view::dsl::*;
+ use super::moderator_views::mod_ban_from_community_view::dsl::*;
let mut query = mod_ban_from_community_view.into_boxed();
let (limit, offset) = limit_and_offset(page, limit);
page: Option<i64>,
limit: Option<i64>,
) -> Result<Vec<Self>, Error> {
- use actions::moderator_views::mod_ban_view::dsl::*;
+ use super::moderator_views::mod_ban_view::dsl::*;
let mut query = mod_ban_view.into_boxed();
let (limit, offset) = limit_and_offset(page, limit);
page: Option<i64>,
limit: Option<i64>,
) -> Result<Vec<Self>, Error> {
- use actions::moderator_views::mod_add_community_view::dsl::*;
+ use super::moderator_views::mod_add_community_view::dsl::*;
let mut query = mod_add_community_view.into_boxed();
let (limit, offset) = limit_and_offset(page, limit);
page: Option<i64>,
limit: Option<i64>,
) -> Result<Vec<Self>, Error> {
- use actions::moderator_views::mod_add_view::dsl::*;
+ use super::moderator_views::mod_add_view::dsl::*;
let mut query = mod_add_view.into_boxed();
let (limit, offset) = limit_and_offset(page, limit);
#[cfg(test)]
mod tests {
use establish_connection;
- use super::*;
use Crud;
- use actions::community::*;
- use actions::user::*;
+ use super::*;
+ use super::super::community::*;
+ use super::super::user::*;
#[test]
fn test_crud() {
let conn = establish_connection();
page: Option<i64>,
limit: Option<i64>,
) -> Result<Vec<Self>, Error> {
- use actions::post_view::post_view::dsl::*;
+ use super::post_view::post_view::dsl::*;
let (limit, offset) = limit_and_offset(page, limit);
pub fn read(conn: &PgConnection, from_post_id: i32, my_user_id: Option<i32>) -> Result<Self, Error> {
- use actions::post_view::post_view::dsl::*;
+ use super::post_view::post_view::dsl::*;
use diesel::prelude::*;
let mut query = post_view.into_boxed();
mod tests {
use {establish_connection, Crud, Likeable};
use super::*;
- use actions::community::*;
- use actions::user::*;
- use actions::post::*;
+ use super::super::community::*;
+ use super::super::user::*;
+ use super::super::post::*;
#[test]
fn test_crud() {
let conn = establish_connection();
impl UserView {
pub fn read(conn: &PgConnection, from_user_id: i32) -> Result<Self, Error> {
- use actions::user_view::user_view::dsl::*;
+ use super::user_view::user_view::dsl::*;
user_view.find(from_user_id)
.first::<Self>(conn)
}
pub fn admins(conn: &PgConnection) -> Result<Vec<Self>, Error> {
- use actions::user_view::user_view::dsl::*;
+ use super::user_view::user_view::dsl::*;
user_view.filter(admin.eq(true))
.load::<Self>(conn)
}
pub fn banned(conn: &PgConnection) -> Result<Vec<Self>, Error> {
- use actions::user_view::user_view::dsl::*;
+ use super::user_view::user_view::dsl::*;
user_view.filter(banned.eq(true))
.load::<Self>(conn)
}
pub mod schema;
pub mod apub;
-pub mod actions;
-pub mod websocket_server;
+pub mod db;
+pub mod websocket;
use diesel::*;
use diesel::pg::PgConnection;
-extern crate server;
+extern crate lemmy_server;
#[macro_use] extern crate diesel_migrations;
use std::time::{Instant, Duration};
use std::env;
-use server::actix::*;
-use server::actix_web::server::HttpServer;
-use server::actix_web::{ws, App, Error, HttpRequest, HttpResponse, fs::NamedFile, fs};
-
-use server::websocket_server::server::*;
-use server::establish_connection;
+use lemmy_server::actix::*;
+use lemmy_server::actix_web::server::HttpServer;
+use lemmy_server::actix_web::{ws, App, Error, HttpRequest, HttpResponse, fs::NamedFile, fs};
+use lemmy_server::websocket::server::*;
+use lemmy_server::establish_connection;
embed_migrations!();
use std::time::{SystemTime};
use {Crud, Joinable, Likeable, Followable, Bannable, Saveable, establish_connection, naive_now, naive_from_unix, SortType, SearchType, has_slurs, remove_slurs, Settings};
-use actions::community::*;
-use actions::user::*;
-use actions::post::*;
-use actions::comment::*;
-use actions::post_view::*;
-use actions::comment_view::*;
-use actions::category::*;
-use actions::community_view::*;
-use actions::user_view::*;
-use actions::moderator_views::*;
-use actions::moderator::*;
+use db::community::*;
+use db::user::*;
+use db::post::*;
+use db::comment::*;
+use db::post_view::*;
+use db::comment_view::*;
+use db::category::*;
+use db::community_view::*;
+use db::user_view::*;
+use db::moderator_views::*;
+use db::moderator::*;
const RATE_LIMIT_MESSAGES: i32 = 30;
const RATE_LIMIT_PER_SECOND: i32 = 60;