source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
-[[package]]
-name = "lemmy_api_structs"
-version = "0.1.0"
-dependencies = [
- "actix-web",
- "diesel",
- "lemmy_db",
- "lemmy_utils",
- "log",
- "serde 1.0.115",
-]
-
[[package]]
name = "lemmy_db"
version = "0.1.0"
"itertools",
"jsonwebtoken",
"lazy_static",
- "lemmy_api_structs",
"lemmy_db",
"lemmy_rate_limit",
+ "lemmy_structs",
"lemmy_utils",
"log",
"openssl",
"serde_json",
"sha2",
"strum",
- "strum_macros",
"thiserror",
"tokio",
"url",
"uuid 0.8.1",
]
+[[package]]
+name = "lemmy_structs"
+version = "0.1.0"
+dependencies = [
+ "actix",
+ "actix-web",
+ "chrono",
+ "diesel",
+ "lemmy_db",
+ "lemmy_utils",
+ "log",
+ "serde 1.0.115",
+ "strum",
+ "strum_macros",
+]
+
[[package]]
name = "lemmy_utils"
version = "0.1.0"
members = [
"lemmy_utils",
"lemmy_db",
- "lemmy_api_structs",
+ "lemmy_structs",
"lemmy_rate_limit",
]
[dependencies]
lemmy_utils = { path = "./lemmy_utils" }
lemmy_db = { path = "./lemmy_db" }
-lemmy_api_structs = { path = "./lemmy_api_structs" }
+lemmy_structs = { path = "./lemmy_structs" }
lemmy_rate_limit = { path = "./lemmy_rate_limit" }
diesel = "1.4.4"
diesel_migrations = "1.4.0"
env_logger = "0.7.1"
rand = "0.7.3"
strum = "0.19.2"
-strum_macros = "0.19.2"
jsonwebtoken = "7.0.1"
lazy_static = "1.3.0"
rss = "1.9.0"
WORKDIR /app/server
RUN mkdir -p lemmy_db/src/ \
lemmy_utils/src/ \
- lemmy_api_structs/src/ \
+ lemmy_structs/src/ \
lemmy_rate_limit/src/ \
lemmy
COPY Cargo.toml Cargo.lock ./
COPY lemmy_db/Cargo.toml ./lemmy_db/
COPY lemmy_utils/Cargo.toml ./lemmy_utils/
-COPY lemmy_api_structs/Cargo.toml ./lemmy_api_structs/
+COPY lemmy_structs/Cargo.toml ./lemmy_structs/
COPY lemmy_rate_limit/Cargo.toml ./lemmy_rate_limit/
# Cache the deps
COPY src ./src/
COPY lemmy_db/src ./lemmy_db/src/
COPY lemmy_utils/src/ ./lemmy_utils/src/
-COPY lemmy_api_structs/src/ ./lemmy_api_structs/src/
+COPY lemmy_structs/src/ ./lemmy_structs/src/
COPY lemmy_rate_limit/src/ ./lemmy_rate_limit/src/
COPY migrations ./migrations/
COPY Cargo.toml Cargo.lock ./
COPY lemmy_db ./lemmy_db
COPY lemmy_utils ./lemmy_utils
-COPY lemmy_api_structs ./lemmy_api_structs
+COPY lemmy_structs ./lemmy_structs
COPY lemmy_rate_limit ./lemmy_rate_limit
RUN mkdir -p ./src/bin \
&& echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs
[package]
-name = "lemmy_api_structs"
+name = "lemmy_structs"
version = "0.1.0"
authors = ["Felix Ableitner <me@nutomic.com>"]
edition = "2018"
[lib]
-name = "lemmy_api_structs"
+name = "lemmy_structs"
path = "src/lib.rs"
[dependencies]
log = "0.4.0"
diesel = "1.4.4"
actix-web = { version = "3.0.0-beta.3", features = ["rustls"] }
+actix = "0.10.0"
+strum = "0.19.2"
+strum_macros = "0.19.2"
+chrono = { version = "0.4.7", features = ["serde"] }
\ No newline at end of file
+extern crate actix;
extern crate actix_web;
extern crate diesel;
extern crate log;
extern crate serde;
+#[macro_use]
+extern crate strum_macros;
+extern crate chrono;
pub mod comment;
pub mod community;
pub mod post;
pub mod site;
pub mod user;
+pub mod websocket;
use diesel::PgConnection;
use lemmy_db::{
-use crate::websocket::UserOperation;
+use crate::{comment::CommentResponse, post::PostResponse};
use actix::{prelude::*, Recipient};
-use lemmy_api_structs::{comment::CommentResponse, post::PostResponse};
use lemmy_utils::{CommunityId, ConnectionId, IPAddr, PostId, UserId};
use serde::{Deserialize, Serialize};
+#[derive(EnumString, ToString, Debug, Clone)]
+pub enum UserOperation {
+ Login,
+ Register,
+ GetCaptcha,
+ CreateCommunity,
+ CreatePost,
+ ListCommunities,
+ ListCategories,
+ GetPost,
+ GetCommunity,
+ CreateComment,
+ EditComment,
+ DeleteComment,
+ RemoveComment,
+ MarkCommentAsRead,
+ SaveComment,
+ CreateCommentLike,
+ GetPosts,
+ CreatePostLike,
+ EditPost,
+ DeletePost,
+ RemovePost,
+ LockPost,
+ StickyPost,
+ SavePost,
+ EditCommunity,
+ DeleteCommunity,
+ RemoveCommunity,
+ FollowCommunity,
+ GetFollowedCommunities,
+ GetUserDetails,
+ GetReplies,
+ GetUserMentions,
+ MarkUserMentionAsRead,
+ GetModlog,
+ BanFromCommunity,
+ AddModToCommunity,
+ CreateSite,
+ EditSite,
+ GetSite,
+ AddAdmin,
+ BanUser,
+ Search,
+ MarkAllAsRead,
+ SaveUserSettings,
+ TransferCommunity,
+ TransferSite,
+ DeleteAccount,
+ PasswordReset,
+ PasswordChange,
+ CreatePrivateMessage,
+ EditPrivateMessage,
+ DeletePrivateMessage,
+ MarkPrivateMessageAsRead,
+ GetPrivateMessages,
+ UserJoin,
+ GetComments,
+ GetSiteConfig,
+ SaveSiteConfig,
+ PostJoin,
+ CommunityJoin,
+}
+
/// Chat server sends this messages to session
#[derive(Message)]
#[rtype(result = "()")]
Perform,
},
apub::{ApubLikeableType, ApubObjectType},
- websocket::{messages::SendComment, UserOperation},
LemmyContext,
};
use actix_web::web::Data;
-use lemmy_api_structs::{blocking, comment::*, send_local_notifs};
+use lemmy_structs::{
+ blocking,
+ comment::*,
+ send_local_notifs,
+ websocket::{SendComment, UserOperation},
+};
use lemmy_db::{
comment::*,
comment_view::*,
use crate::{
api::{get_user_from_jwt, get_user_from_jwt_opt, is_admin, is_mod_or_admin, Perform},
apub::ActorType,
- websocket::{
- messages::{GetCommunityUsersOnline, JoinCommunityRoom, SendCommunityRoomMessage},
- UserOperation,
- },
LemmyContext,
};
use actix_web::web::Data;
use anyhow::Context;
-use lemmy_api_structs::{blocking, community::*};
+use lemmy_structs::{
+ blocking,
+ community::*,
+ websocket::{
+ GetCommunityUsersOnline,
+ JoinCommunityRoom,
+ SendCommunityRoomMessage,
+ UserOperation,
+ },
+};
use lemmy_db::{
comment::Comment,
comment_view::CommentQueryBuilder,
use crate::{api::claims::Claims, DbPool, LemmyContext};
use actix_web::web::Data;
-use lemmy_api_structs::blocking;
+use lemmy_structs::blocking;
use lemmy_db::{
community::Community,
community_view::CommunityUserBanView,
api::{check_community_ban, get_user_from_jwt, get_user_from_jwt_opt, is_mod_or_admin, Perform},
apub::{ApubLikeableType, ApubObjectType},
fetch_iframely_and_pictrs_data,
- websocket::{
- messages::{GetPostUsersOnline, JoinPostRoom, SendPost},
- UserOperation,
- },
LemmyContext,
};
use actix_web::web::Data;
-use lemmy_api_structs::{blocking, post::*};
+use lemmy_structs::{
+ blocking,
+ post::*,
+ websocket::{GetPostUsersOnline, JoinPostRoom, SendPost, UserOperation},
+};
use lemmy_db::{
comment_view::*,
community_view::*,
api::{get_user_from_jwt, get_user_from_jwt_opt, is_admin, Perform},
apub::fetcher::search_by_apub_id,
version,
- websocket::{
- messages::{GetUsersOnline, SendAllMessage},
- UserOperation,
- },
LemmyContext,
};
use actix_web::web::Data;
use anyhow::Context;
-use lemmy_api_structs::{blocking, site::*, user::Register};
+use lemmy_structs::{
+ blocking,
+ site::*,
+ user::Register,
+ websocket::{GetUsersOnline, SendAllMessage, UserOperation},
+};
use lemmy_db::{
category::*,
comment_view::*,
api::{claims::Claims, get_user_from_jwt, get_user_from_jwt_opt, is_admin, Perform},
apub::ApubObjectType,
captcha_espeak_wav_base64,
- websocket::{
- messages::{CaptchaItem, CheckCaptcha, JoinUserRoom, SendAllMessage, SendUserRoomMessage},
- UserOperation,
- },
LemmyContext,
};
use actix_web::web::Data;
use bcrypt::verify;
use captcha::{gen, Difficulty};
use chrono::Duration;
-use lemmy_api_structs::{blocking, user::*};
+use lemmy_structs::{
+ blocking,
+ user::*,
+ websocket::{
+ CaptchaItem,
+ CheckCaptcha,
+ JoinUserRoom,
+ SendAllMessage,
+ SendUserRoomMessage,
+ UserOperation,
+ },
+};
use lemmy_db::{
comment::*,
comment_view::*,
use actix_web::{body::Body, web, web::Path, HttpResponse};
use anyhow::Context;
use itertools::Itertools;
-use lemmy_api_structs::blocking;
+use lemmy_structs::blocking;
use lemmy_db::{
comment::{Comment, CommentForm},
community::Community,
use actix_web::{body::Body, web, HttpResponse};
use anyhow::Context;
use itertools::Itertools;
-use lemmy_api_structs::blocking;
+use lemmy_structs::blocking;
use lemmy_db::{
community::{Community, CommunityForm},
community_view::{CommunityFollowerView, CommunityModeratorView},
use anyhow::{anyhow, Context};
use chrono::NaiveDateTime;
use diesel::result::Error::NotFound;
-use lemmy_api_structs::{blocking, site::SearchResponse};
+use lemmy_structs::{blocking, site::SearchResponse};
use lemmy_db::{
comment::{Comment, CommentForm},
comment_view::CommentView,
FromApub,
PageExt,
},
- websocket::{
- messages::{SendComment, SendPost},
- UserOperation,
- },
LemmyContext,
};
use activitystreams::{activity::Create, base::AnyBase, object::Note, prelude::*};
use actix_web::HttpResponse;
use anyhow::Context;
-use lemmy_api_structs::{
+use lemmy_structs::{
blocking,
comment::CommentResponse,
post::PostResponse,
send_local_notifs,
+ websocket::{SendComment, SendPost, UserOperation},
};
use lemmy_db::{
comment::{Comment, CommentForm},
GroupExt,
PageExt,
},
- websocket::{
- messages::{SendComment, SendCommunityRoomMessage, SendPost},
- UserOperation,
- },
LemmyContext,
};
use activitystreams::{activity::Delete, base::AnyBase, object::Note, prelude::*};
use actix_web::HttpResponse;
use anyhow::Context;
-use lemmy_api_structs::{
+use lemmy_structs::{
blocking,
comment::CommentResponse,
community::CommunityResponse,
post::PostResponse,
+ websocket::{SendComment, SendCommunityRoomMessage, SendPost, UserOperation},
};
use lemmy_db::{
comment::{Comment, CommentForm},
FromApub,
PageExt,
},
- websocket::{
- messages::{SendComment, SendPost},
- UserOperation,
- },
LemmyContext,
};
use activitystreams::{activity::Dislike, base::AnyBase, object::Note, prelude::*};
use actix_web::HttpResponse;
use anyhow::Context;
-use lemmy_api_structs::{blocking, comment::CommentResponse, post::PostResponse};
+use lemmy_structs::{
+ blocking,
+ comment::CommentResponse,
+ post::PostResponse,
+ websocket::{SendComment, SendPost, UserOperation},
+};
use lemmy_db::{
comment::{CommentForm, CommentLike, CommentLikeForm},
comment_view::CommentView,
FromApub,
PageExt,
},
- websocket::{
- messages::{SendComment, SendPost},
- UserOperation,
- },
LemmyContext,
};
use activitystreams::{activity::Like, base::AnyBase, object::Note, prelude::*};
use actix_web::HttpResponse;
use anyhow::Context;
-use lemmy_api_structs::{blocking, comment::CommentResponse, post::PostResponse};
+use lemmy_structs::{
+ blocking,
+ comment::CommentResponse,
+ post::PostResponse,
+ websocket::{SendComment, SendPost, UserOperation},
+};
use lemmy_db::{
comment::{CommentForm, CommentLike, CommentLikeForm},
comment_view::CommentView,
GroupExt,
PageExt,
},
- websocket::{
- messages::{SendComment, SendCommunityRoomMessage, SendPost},
- UserOperation,
- },
LemmyContext,
};
use activitystreams::{activity::Remove, base::AnyBase, object::Note, prelude::*};
use actix_web::HttpResponse;
use anyhow::{anyhow, Context};
-use lemmy_api_structs::{
+use lemmy_structs::{
blocking,
comment::CommentResponse,
community::CommunityResponse,
post::PostResponse,
+ websocket::{SendComment, SendCommunityRoomMessage, SendPost, UserOperation},
};
use lemmy_db::{
comment::{Comment, CommentForm},
GroupExt,
PageExt,
},
- websocket::{
- messages::{SendComment, SendCommunityRoomMessage, SendPost},
- UserOperation,
- },
LemmyContext,
};
use activitystreams::{
};
use actix_web::HttpResponse;
use anyhow::{anyhow, Context};
-use lemmy_api_structs::{
+use lemmy_structs::{
blocking,
comment::CommentResponse,
community::CommunityResponse,
post::PostResponse,
+ websocket::{SendComment, SendCommunityRoomMessage, SendPost, UserOperation},
};
use lemmy_db::{
comment::{Comment, CommentForm, CommentLike},
FromApub,
PageExt,
},
- websocket::{
- messages::{SendComment, SendPost},
- UserOperation,
- },
LemmyContext,
};
use activitystreams::{activity::Update, base::AnyBase, object::Note, prelude::*};
use actix_web::HttpResponse;
use anyhow::Context;
-use lemmy_api_structs::{
+use lemmy_structs::{
blocking,
comment::CommentResponse,
post::PostResponse,
send_local_notifs,
+ websocket::{SendComment, SendPost, UserOperation},
};
use lemmy_db::{
comment::{Comment, CommentForm},
};
use actix_web::{web, HttpRequest, HttpResponse};
use anyhow::{anyhow, Context};
-use lemmy_api_structs::blocking;
+use lemmy_structs::blocking;
use lemmy_db::{
community::{Community, CommunityFollower, CommunityFollowerForm},
user::User_,
insert_activity,
FromApub,
},
- websocket::{messages::SendUserRoomMessage, UserOperation},
LemmyContext,
};
use activitystreams::{
};
use actix_web::{web, HttpRequest, HttpResponse};
use anyhow::Context;
-use lemmy_api_structs::{blocking, user::PrivateMessageResponse};
+use lemmy_structs::{
+ blocking,
+ user::PrivateMessageResponse,
+ websocket::{SendUserRoomMessage, UserOperation},
+};
use lemmy_db::{
community::{CommunityFollower, CommunityFollowerForm},
naive_now,
use actix_web::{body::Body, HttpResponse};
use anyhow::{anyhow, Context};
use chrono::NaiveDateTime;
-use lemmy_api_structs::blocking;
+use lemmy_structs::blocking;
use lemmy_db::{activity::do_insert_activity, user::User_};
use lemmy_utils::{
apub::get_apub_protocol_string,
use activitystreams_ext::Ext1;
use actix_web::{body::Body, web, HttpResponse};
use anyhow::Context;
-use lemmy_api_structs::blocking;
+use lemmy_structs::blocking;
use lemmy_db::{
community::Community,
post::{Post, PostForm},
prelude::*,
};
use anyhow::Context;
-use lemmy_api_structs::blocking;
+use lemmy_structs::blocking;
use lemmy_db::{
private_message::{PrivateMessage, PrivateMessageForm},
user::User_,
use activitystreams_ext::Ext1;
use actix_web::{body::Body, web, HttpResponse};
use anyhow::Context;
-use lemmy_api_structs::blocking;
+use lemmy_structs::blocking;
use lemmy_db::{
naive_now,
user::{UserForm, User_},
#![recursion_limit = "512"]
#[macro_use]
-extern crate strum_macros;
-#[macro_use]
extern crate lazy_static;
extern crate actix;
extern crate actix_web;
PgConnection,
};
use lazy_static::lazy_static;
-use lemmy_api_structs::blocking;
+use lemmy_structs::blocking;
use lemmy_db::get_database_url_from_env;
use lemmy_rate_limit::{rate_limiter::RateLimiter, RateLimit};
use lemmy_server::{
use crate::{api::Perform, LemmyContext};
use actix_web::{error::ErrorBadRequest, *};
-use lemmy_api_structs::{comment::*, community::*, post::*, site::*, user::*};
+use lemmy_structs::{comment::*, community::*, post::*, site::*, user::*};
use lemmy_rate_limit::RateLimit;
use serde::Deserialize;
use anyhow::anyhow;
use chrono::{DateTime, NaiveDateTime, Utc};
use diesel::PgConnection;
-use lemmy_api_structs::blocking;
+use lemmy_structs::blocking;
use lemmy_db::{
comment_view::{ReplyQueryBuilder, ReplyView},
community::Community,
use crate::{version, LemmyContext};
use actix_web::{body::Body, error::ErrorBadRequest, *};
use anyhow::anyhow;
-use lemmy_api_structs::blocking;
+use lemmy_structs::blocking;
use lemmy_db::site_view::SiteView;
use lemmy_utils::{apub::get_apub_protocol_string, settings::Settings, LemmyError};
use serde::{Deserialize, Serialize};
use crate::LemmyContext;
use actix_web::{error::ErrorBadRequest, web::Query, *};
use anyhow::anyhow;
-use lemmy_api_structs::blocking;
+use lemmy_structs::blocking;
use lemmy_db::{community::Community, user::User_};
use lemmy_utils::{
settings::Settings,
-use crate::{
- websocket::{
- chat_server::ChatServer,
- messages::{Connect, Disconnect, StandardMessage, WSMessage},
- },
- LemmyContext,
-};
+use crate::{websocket::chat_server::ChatServer, LemmyContext};
use actix::prelude::*;
use actix_web::*;
use actix_web_actors::ws;
+use lemmy_structs::websocket::{Connect, Disconnect, StandardMessage, WSMessage};
use lemmy_utils::utils::get_ip;
use log::{debug, error, info};
use std::time::{Duration, Instant};
use crate::{
- websocket::{
- handlers::{do_user_operation, to_json_string, Args},
- messages::*,
- UserOperation,
- },
+ websocket::handlers::{do_user_operation, to_json_string, Args},
LemmyContext,
};
use actix::prelude::*;
r2d2::{ConnectionManager, Pool},
PgConnection,
};
-use lemmy_api_structs::{comment::*, community::*, post::*, site::*, user::*};
+use lemmy_structs::{comment::*, community::*, post::*, site::*, user::*, websocket::*};
use lemmy_rate_limit::RateLimit;
use lemmy_utils::{
location_info,
use crate::{
api::Perform,
- websocket::{
- chat_server::{ChatServer, SessionInfo},
- messages::*,
- UserOperation,
- },
+ websocket::chat_server::{ChatServer, SessionInfo},
LemmyContext,
};
use actix::{Actor, Context, Handler, ResponseFuture};
use actix_web::web;
+use lemmy_structs::websocket::*;
use lemmy_db::naive_now;
use lemmy_rate_limit::RateLimit;
use lemmy_utils::{ConnectionId, IPAddr, LemmyError};
pub mod chat_server;
pub mod handlers;
-pub mod messages;
-
-#[derive(EnumString, ToString, Debug, Clone)]
-pub enum UserOperation {
- Login,
- Register,
- GetCaptcha,
- CreateCommunity,
- CreatePost,
- ListCommunities,
- ListCategories,
- GetPost,
- GetCommunity,
- CreateComment,
- EditComment,
- DeleteComment,
- RemoveComment,
- MarkCommentAsRead,
- SaveComment,
- CreateCommentLike,
- GetPosts,
- CreatePostLike,
- EditPost,
- DeletePost,
- RemovePost,
- LockPost,
- StickyPost,
- SavePost,
- EditCommunity,
- DeleteCommunity,
- RemoveCommunity,
- FollowCommunity,
- GetFollowedCommunities,
- GetUserDetails,
- GetReplies,
- GetUserMentions,
- MarkUserMentionAsRead,
- GetModlog,
- BanFromCommunity,
- AddModToCommunity,
- CreateSite,
- EditSite,
- GetSite,
- AddAdmin,
- BanUser,
- Search,
- MarkAllAsRead,
- SaveUserSettings,
- TransferCommunity,
- TransferSite,
- DeleteAccount,
- PasswordReset,
- PasswordChange,
- CreatePrivateMessage,
- EditPrivateMessage,
- DeletePrivateMessage,
- MarkPrivateMessageAsRead,
- GetPrivateMessages,
- UserJoin,
- GetComments,
- GetSiteConfig,
- SaveSiteConfig,
- PostJoin,
- CommunityJoin,
-}