name = "lemmy_server"
version = "0.0.1"
authors = ["Dessalines <happydooby@gmail.com>"]
+edition = "2018"
[dependencies]
diesel = { version = "1.4.2", features = ["postgres","chrono"] }
use serde::{Deserialize, Serialize};
use failure::Error;
-use db::*;
-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::*;
-use {has_slurs, remove_slurs, Settings, naive_now, naive_from_unix};
+use crate::db::*;
+use crate::db::community::*;
+use crate::db::user::*;
+use crate::db::post::*;
+use crate::db::comment::*;
+use crate::db::post_view::*;
+use crate::db::comment_view::*;
+use crate::db::category::*;
+use crate::db::community_view::*;
+use crate::db::user_view::*;
+use crate::db::moderator_views::*;
+use crate::db::moderator::*;
+use crate::{has_slurs, remove_slurs, Settings, naive_now, naive_from_unix};
pub mod user;
pub mod community;
extern crate activitypub;
use self::activitypub::{context, actor::Person};
-use db::user::User_;
+use crate::db::user::User_;
impl User_ {
pub fn person(&self) -> Person {
- use {Settings, to_datetime_utc};
+ use crate::{Settings, to_datetime_utc};
let base_url = &format!("{}/user/{}", Settings::get().api_endpoint(), self.name);
let mut person = Person::default();
person.object_props.set_context_object(context()).ok();
#[cfg(test)]
mod tests {
use super::User_;
- use naive_now;
+ use crate::naive_now;
#[test]
fn test_person() {
-use schema::{category};
-use schema::category::dsl::*;
+use crate::schema::{category};
+use crate::schema::category::dsl::*;
use super::*;
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
-use schema::{comment, comment_like, comment_saved};
+use crate::schema::{comment, comment_like, comment_saved};
use super::*;
use super::post::Post;
impl Crud<CommentForm> for Comment {
fn read(conn: &PgConnection, comment_id: i32) -> Result<Self, Error> {
- use schema::comment::dsl::*;
+ use crate::schema::comment::dsl::*;
comment.find(comment_id)
.first::<Self>(conn)
}
fn delete(conn: &PgConnection, comment_id: i32) -> Result<usize, Error> {
- use schema::comment::dsl::*;
+ use crate::schema::comment::dsl::*;
diesel::delete(comment.find(comment_id))
.execute(conn)
}
fn create(conn: &PgConnection, comment_form: &CommentForm) -> Result<Self, Error> {
- use schema::comment::dsl::*;
+ use crate::schema::comment::dsl::*;
insert_into(comment)
.values(comment_form)
.get_result::<Self>(conn)
}
fn update(conn: &PgConnection, comment_id: i32, comment_form: &CommentForm) -> Result<Self, Error> {
- use schema::comment::dsl::*;
+ use crate::schema::comment::dsl::*;
diesel::update(comment.find(comment_id))
.set(comment_form)
.get_result::<Self>(conn)
impl Likeable <CommentLikeForm> for CommentLike {
fn read(conn: &PgConnection, comment_id_from: i32) -> Result<Vec<Self>, Error> {
- use schema::comment_like::dsl::*;
+ use crate::schema::comment_like::dsl::*;
comment_like
.filter(comment_id.eq(comment_id_from))
.load::<Self>(conn)
}
fn like(conn: &PgConnection, comment_like_form: &CommentLikeForm) -> Result<Self, Error> {
- use schema::comment_like::dsl::*;
+ use crate::schema::comment_like::dsl::*;
insert_into(comment_like)
.values(comment_like_form)
.get_result::<Self>(conn)
}
fn remove(conn: &PgConnection, comment_like_form: &CommentLikeForm) -> Result<usize, Error> {
- use schema::comment_like::dsl::*;
+ use crate::schema::comment_like::dsl::*;
diesel::delete(comment_like
.filter(comment_id.eq(comment_like_form.comment_id))
.filter(user_id.eq(comment_like_form.user_id)))
impl CommentLike {
pub fn from_post(conn: &PgConnection, post_id_from: i32) -> Result<Vec<Self>, Error> {
- use schema::comment_like::dsl::*;
+ use crate::schema::comment_like::dsl::*;
comment_like
.filter(post_id.eq(post_id_from))
.load::<Self>(conn)
impl Saveable <CommentSavedForm> for CommentSaved {
fn save(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result<Self, Error> {
- use schema::comment_saved::dsl::*;
+ use crate::schema::comment_saved::dsl::*;
insert_into(comment_saved)
.values(comment_saved_form)
.get_result::<Self>(conn)
}
fn unsave(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result<usize, Error> {
- use schema::comment_saved::dsl::*;
+ use crate::schema::comment_saved::dsl::*;
diesel::delete(comment_saved
.filter(comment_id.eq(comment_saved_form.comment_id))
.filter(user_id.eq(comment_saved_form.user_id)))
-use schema::{community, community_moderator, community_follower, community_user_ban, site};
+use crate::schema::{community, community_moderator, community_follower, community_user_ban, site};
use super::*;
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
impl Crud<CommunityForm> for Community {
fn read(conn: &PgConnection, community_id: i32) -> Result<Self, Error> {
- use schema::community::dsl::*;
+ use crate::schema::community::dsl::*;
community.find(community_id)
.first::<Self>(conn)
}
fn delete(conn: &PgConnection, community_id: i32) -> Result<usize, Error> {
- use schema::community::dsl::*;
+ use crate::schema::community::dsl::*;
diesel::delete(community.find(community_id))
.execute(conn)
}
fn create(conn: &PgConnection, new_community: &CommunityForm) -> Result<Self, Error> {
- use schema::community::dsl::*;
+ use crate::schema::community::dsl::*;
insert_into(community)
.values(new_community)
.get_result::<Self>(conn)
}
fn update(conn: &PgConnection, community_id: i32, new_community: &CommunityForm) -> Result<Self, Error> {
- use schema::community::dsl::*;
+ use crate::schema::community::dsl::*;
diesel::update(community.find(community_id))
.set(new_community)
.get_result::<Self>(conn)
impl Community {
pub fn read_from_name(conn: &PgConnection, community_name: String) -> Result<Self, Error> {
- use schema::community::dsl::*;
+ use crate::schema::community::dsl::*;
community.filter(name.eq(community_name))
.first::<Self>(conn)
}
impl Joinable<CommunityModeratorForm> for CommunityModerator {
fn join(conn: &PgConnection, community_user_form: &CommunityModeratorForm) -> Result<Self, Error> {
- use schema::community_moderator::dsl::*;
+ use crate::schema::community_moderator::dsl::*;
insert_into(community_moderator)
.values(community_user_form)
.get_result::<Self>(conn)
}
fn leave(conn: &PgConnection, community_user_form: &CommunityModeratorForm) -> Result<usize, Error> {
- use schema::community_moderator::dsl::*;
+ use crate::schema::community_moderator::dsl::*;
diesel::delete(community_moderator
.filter(community_id.eq(community_user_form.community_id))
.filter(user_id.eq(community_user_form.user_id)))
impl Bannable<CommunityUserBanForm> for CommunityUserBan {
fn ban(conn: &PgConnection, community_user_ban_form: &CommunityUserBanForm) -> Result<Self, Error> {
- use schema::community_user_ban::dsl::*;
+ use crate::schema::community_user_ban::dsl::*;
insert_into(community_user_ban)
.values(community_user_ban_form)
.get_result::<Self>(conn)
}
fn unban(conn: &PgConnection, community_user_ban_form: &CommunityUserBanForm) -> Result<usize, Error> {
- use schema::community_user_ban::dsl::*;
+ use crate::schema::community_user_ban::dsl::*;
diesel::delete(community_user_ban
.filter(community_id.eq(community_user_ban_form.community_id))
.filter(user_id.eq(community_user_ban_form.user_id)))
impl Followable<CommunityFollowerForm> for CommunityFollower {
fn follow(conn: &PgConnection, community_follower_form: &CommunityFollowerForm) -> Result<Self, Error> {
- use schema::community_follower::dsl::*;
+ use crate::schema::community_follower::dsl::*;
insert_into(community_follower)
.values(community_follower_form)
.get_result::<Self>(conn)
}
fn ignore(conn: &PgConnection, community_follower_form: &CommunityFollowerForm) -> Result<usize, Error> {
- use schema::community_follower::dsl::*;
+ use crate::schema::community_follower::dsl::*;
diesel::delete(community_follower
.filter(community_id.eq(&community_follower_form.community_id))
.filter(user_id.eq(&community_follower_form.user_id)))
impl Crud<SiteForm> for Site {
fn read(conn: &PgConnection, _site_id: i32) -> Result<Self, Error> {
- use schema::site::dsl::*;
+ use crate::schema::site::dsl::*;
site.first::<Self>(conn)
}
fn delete(conn: &PgConnection, site_id: i32) -> Result<usize, Error> {
- use schema::site::dsl::*;
+ use crate::schema::site::dsl::*;
diesel::delete(site.find(site_id))
.execute(conn)
}
fn create(conn: &PgConnection, new_site: &SiteForm) -> Result<Self, Error> {
- use schema::site::dsl::*;
+ use crate::schema::site::dsl::*;
insert_into(site)
.values(new_site)
.get_result::<Self>(conn)
}
fn update(conn: &PgConnection, site_id: i32, new_site: &SiteForm) -> Result<Self, Error> {
- use schema::site::dsl::*;
+ use crate::schema::site::dsl::*;
diesel::update(site.find(site_id))
.set(new_site)
.get_result::<Self>(conn)
use diesel::*;
use diesel::dsl::*;
use diesel::result::Error;
-use {Settings};
+use crate::{Settings};
use serde::{Deserialize, Serialize};
pub mod user;
-use schema::{mod_remove_post, mod_lock_post, mod_remove_comment, mod_remove_community, mod_ban_from_community, mod_ban, mod_add_community, mod_add};
+use crate::schema::{mod_remove_post, mod_lock_post, mod_remove_comment, mod_remove_community, mod_ban_from_community, mod_ban, mod_add_community, mod_add};
use super::*;
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
impl Crud<ModRemovePostForm> for ModRemovePost {
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
- use schema::mod_remove_post::dsl::*;
+ use crate::schema::mod_remove_post::dsl::*;
mod_remove_post.find(from_id)
.first::<Self>(conn)
}
fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
- use schema::mod_remove_post::dsl::*;
+ use crate::schema::mod_remove_post::dsl::*;
diesel::delete(mod_remove_post.find(from_id))
.execute(conn)
}
fn create(conn: &PgConnection, form: &ModRemovePostForm) -> Result<Self, Error> {
- use schema::mod_remove_post::dsl::*;
+ use crate::schema::mod_remove_post::dsl::*;
insert_into(mod_remove_post)
.values(form)
.get_result::<Self>(conn)
}
fn update(conn: &PgConnection, from_id: i32, form: &ModRemovePostForm) -> Result<Self, Error> {
- use schema::mod_remove_post::dsl::*;
+ use crate::schema::mod_remove_post::dsl::*;
diesel::update(mod_remove_post.find(from_id))
.set(form)
.get_result::<Self>(conn)
impl Crud<ModLockPostForm> for ModLockPost {
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
- use schema::mod_lock_post::dsl::*;
+ use crate::schema::mod_lock_post::dsl::*;
mod_lock_post.find(from_id)
.first::<Self>(conn)
}
fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
- use schema::mod_lock_post::dsl::*;
+ use crate::schema::mod_lock_post::dsl::*;
diesel::delete(mod_lock_post.find(from_id))
.execute(conn)
}
fn create(conn: &PgConnection, form: &ModLockPostForm) -> Result<Self, Error> {
- use schema::mod_lock_post::dsl::*;
+ use crate::schema::mod_lock_post::dsl::*;
insert_into(mod_lock_post)
.values(form)
.get_result::<Self>(conn)
}
fn update(conn: &PgConnection, from_id: i32, form: &ModLockPostForm) -> Result<Self, Error> {
- use schema::mod_lock_post::dsl::*;
+ use crate::schema::mod_lock_post::dsl::*;
diesel::update(mod_lock_post.find(from_id))
.set(form)
.get_result::<Self>(conn)
impl Crud<ModRemoveCommentForm> for ModRemoveComment {
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
- use schema::mod_remove_comment::dsl::*;
+ use crate::schema::mod_remove_comment::dsl::*;
mod_remove_comment.find(from_id)
.first::<Self>(conn)
}
fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
- use schema::mod_remove_comment::dsl::*;
+ use crate::schema::mod_remove_comment::dsl::*;
diesel::delete(mod_remove_comment.find(from_id))
.execute(conn)
}
fn create(conn: &PgConnection, form: &ModRemoveCommentForm) -> Result<Self, Error> {
- use schema::mod_remove_comment::dsl::*;
+ use crate::schema::mod_remove_comment::dsl::*;
insert_into(mod_remove_comment)
.values(form)
.get_result::<Self>(conn)
}
fn update(conn: &PgConnection, from_id: i32, form: &ModRemoveCommentForm) -> Result<Self, Error> {
- use schema::mod_remove_comment::dsl::*;
+ use crate::schema::mod_remove_comment::dsl::*;
diesel::update(mod_remove_comment.find(from_id))
.set(form)
.get_result::<Self>(conn)
impl Crud<ModRemoveCommunityForm> for ModRemoveCommunity {
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
- use schema::mod_remove_community::dsl::*;
+ use crate::schema::mod_remove_community::dsl::*;
mod_remove_community.find(from_id)
.first::<Self>(conn)
}
fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
- use schema::mod_remove_community::dsl::*;
+ use crate::schema::mod_remove_community::dsl::*;
diesel::delete(mod_remove_community.find(from_id))
.execute(conn)
}
fn create(conn: &PgConnection, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
- use schema::mod_remove_community::dsl::*;
+ use crate::schema::mod_remove_community::dsl::*;
insert_into(mod_remove_community)
.values(form)
.get_result::<Self>(conn)
}
fn update(conn: &PgConnection, from_id: i32, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
- use schema::mod_remove_community::dsl::*;
+ use crate::schema::mod_remove_community::dsl::*;
diesel::update(mod_remove_community.find(from_id))
.set(form)
.get_result::<Self>(conn)
impl Crud<ModBanFromCommunityForm> for ModBanFromCommunity {
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
- use schema::mod_ban_from_community::dsl::*;
+ use crate::schema::mod_ban_from_community::dsl::*;
mod_ban_from_community.find(from_id)
.first::<Self>(conn)
}
fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
- use schema::mod_ban_from_community::dsl::*;
+ use crate::schema::mod_ban_from_community::dsl::*;
diesel::delete(mod_ban_from_community.find(from_id))
.execute(conn)
}
fn create(conn: &PgConnection, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
- use schema::mod_ban_from_community::dsl::*;
+ use crate::schema::mod_ban_from_community::dsl::*;
insert_into(mod_ban_from_community)
.values(form)
.get_result::<Self>(conn)
}
fn update(conn: &PgConnection, from_id: i32, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
- use schema::mod_ban_from_community::dsl::*;
+ use crate::schema::mod_ban_from_community::dsl::*;
diesel::update(mod_ban_from_community.find(from_id))
.set(form)
.get_result::<Self>(conn)
impl Crud<ModBanForm> for ModBan {
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
- use schema::mod_ban::dsl::*;
+ use crate::schema::mod_ban::dsl::*;
mod_ban.find(from_id)
.first::<Self>(conn)
}
fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
- use schema::mod_ban::dsl::*;
+ use crate::schema::mod_ban::dsl::*;
diesel::delete(mod_ban.find(from_id))
.execute(conn)
}
fn create(conn: &PgConnection, form: &ModBanForm) -> Result<Self, Error> {
- use schema::mod_ban::dsl::*;
+ use crate::schema::mod_ban::dsl::*;
insert_into(mod_ban)
.values(form)
.get_result::<Self>(conn)
}
fn update(conn: &PgConnection, from_id: i32, form: &ModBanForm) -> Result<Self, Error> {
- use schema::mod_ban::dsl::*;
+ use crate::schema::mod_ban::dsl::*;
diesel::update(mod_ban.find(from_id))
.set(form)
.get_result::<Self>(conn)
impl Crud<ModAddCommunityForm> for ModAddCommunity {
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
- use schema::mod_add_community::dsl::*;
+ use crate::schema::mod_add_community::dsl::*;
mod_add_community.find(from_id)
.first::<Self>(conn)
}
fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
- use schema::mod_add_community::dsl::*;
+ use crate::schema::mod_add_community::dsl::*;
diesel::delete(mod_add_community.find(from_id))
.execute(conn)
}
fn create(conn: &PgConnection, form: &ModAddCommunityForm) -> Result<Self, Error> {
- use schema::mod_add_community::dsl::*;
+ use crate::schema::mod_add_community::dsl::*;
insert_into(mod_add_community)
.values(form)
.get_result::<Self>(conn)
}
fn update(conn: &PgConnection, from_id: i32, form: &ModAddCommunityForm) -> Result<Self, Error> {
- use schema::mod_add_community::dsl::*;
+ use crate::schema::mod_add_community::dsl::*;
diesel::update(mod_add_community.find(from_id))
.set(form)
.get_result::<Self>(conn)
impl Crud<ModAddForm> for ModAdd {
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
- use schema::mod_add::dsl::*;
+ use crate::schema::mod_add::dsl::*;
mod_add.find(from_id)
.first::<Self>(conn)
}
fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
- use schema::mod_add::dsl::*;
+ use crate::schema::mod_add::dsl::*;
diesel::delete(mod_add.find(from_id))
.execute(conn)
}
fn create(conn: &PgConnection, form: &ModAddForm) -> Result<Self, Error> {
- use schema::mod_add::dsl::*;
+ use crate::schema::mod_add::dsl::*;
insert_into(mod_add)
.values(form)
.get_result::<Self>(conn)
}
fn update(conn: &PgConnection, from_id: i32, form: &ModAddForm) -> Result<Self, Error> {
- use schema::mod_add::dsl::*;
+ use crate::schema::mod_add::dsl::*;
diesel::update(mod_add.find(from_id))
.set(form)
.get_result::<Self>(conn)
-use schema::{post, post_like, post_saved, post_read};
+use crate::schema::{post, post_like, post_saved, post_read};
use super::*;
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
impl Crud<PostForm> for Post {
fn read(conn: &PgConnection, post_id: i32) -> Result<Self, Error> {
- use schema::post::dsl::*;
+ use crate::schema::post::dsl::*;
post.find(post_id)
.first::<Self>(conn)
}
fn delete(conn: &PgConnection, post_id: i32) -> Result<usize, Error> {
- use schema::post::dsl::*;
+ use crate::schema::post::dsl::*;
diesel::delete(post.find(post_id))
.execute(conn)
}
fn create(conn: &PgConnection, new_post: &PostForm) -> Result<Self, Error> {
- use schema::post::dsl::*;
+ use crate::schema::post::dsl::*;
insert_into(post)
.values(new_post)
.get_result::<Self>(conn)
}
fn update(conn: &PgConnection, post_id: i32, new_post: &PostForm) -> Result<Self, Error> {
- use schema::post::dsl::*;
+ use crate::schema::post::dsl::*;
diesel::update(post.find(post_id))
.set(new_post)
.get_result::<Self>(conn)
impl Likeable <PostLikeForm> for PostLike {
fn read(conn: &PgConnection, post_id_from: i32) -> Result<Vec<Self>, Error> {
- use schema::post_like::dsl::*;
+ use crate::schema::post_like::dsl::*;
post_like
.filter(post_id.eq(post_id_from))
.load::<Self>(conn)
}
fn like(conn: &PgConnection, post_like_form: &PostLikeForm) -> Result<Self, Error> {
- use schema::post_like::dsl::*;
+ use crate::schema::post_like::dsl::*;
insert_into(post_like)
.values(post_like_form)
.get_result::<Self>(conn)
}
fn remove(conn: &PgConnection, post_like_form: &PostLikeForm) -> Result<usize, Error> {
- use schema::post_like::dsl::*;
+ use crate::schema::post_like::dsl::*;
diesel::delete(post_like
.filter(post_id.eq(post_like_form.post_id))
.filter(user_id.eq(post_like_form.user_id)))
impl Saveable <PostSavedForm> for PostSaved {
fn save(conn: &PgConnection, post_saved_form: &PostSavedForm) -> Result<Self, Error> {
- use schema::post_saved::dsl::*;
+ use crate::schema::post_saved::dsl::*;
insert_into(post_saved)
.values(post_saved_form)
.get_result::<Self>(conn)
}
fn unsave(conn: &PgConnection, post_saved_form: &PostSavedForm) -> Result<usize, Error> {
- use schema::post_saved::dsl::*;
+ use crate::schema::post_saved::dsl::*;
diesel::delete(post_saved
.filter(post_id.eq(post_saved_form.post_id))
.filter(user_id.eq(post_saved_form.user_id)))
impl Readable <PostReadForm> for PostRead {
fn mark_as_read(conn: &PgConnection, post_read_form: &PostReadForm) -> Result<Self, Error> {
- use schema::post_read::dsl::*;
+ use crate::schema::post_read::dsl::*;
insert_into(post_read)
.values(post_read_form)
.get_result::<Self>(conn)
}
fn mark_as_unread(conn: &PgConnection, post_read_form: &PostReadForm) -> Result<usize, Error> {
- use schema::post_read::dsl::*;
+ use crate::schema::post_read::dsl::*;
diesel::delete(post_read
.filter(post_id.eq(post_read_form.post_id))
.filter(user_id.eq(post_read_form.user_id)))
-use schema::user_;
-use schema::user_::dsl::*;
+use crate::schema::user_;
+use crate::schema::user_::dsl::*;
use super::*;
-use {Settings, is_email_regex};
+use crate::{Settings, is_email_regex};
use jsonwebtoken::{encode, decode, Header, Validation, TokenData};
use bcrypt::{DEFAULT_COST, hash};
impl Crud<UserForm> for User_ {
fn read(conn: &PgConnection, user_id: i32) -> Result<Self, Error> {
- use schema::user_::dsl::*;
+ use crate::schema::user_::dsl::*;
user_.find(user_id)
.first::<Self>(conn)
}
#[cfg(test)]
mod tests {
- use {Settings, is_email_regex, remove_slurs, has_slurs};
+ use crate::{Settings, is_email_regex, remove_slurs, has_slurs};
#[test]
fn test_api() {
assert_eq!(Settings::get().api_endpoint(), "rrr/api/v1");
use failure::Error;
use std::time::{SystemTime};
-use api::*;
-use api::user::*;
-use api::community::*;
-use api::post::*;
-use api::comment::*;
-use api::site::*;
+use crate::api::*;
+use crate::api::user::*;
+use crate::api::community::*;
+use crate::api::post::*;
+use crate::api::comment::*;
+use crate::api::site::*;
const RATE_LIMIT_MESSAGES: i32 = 30;
const RATE_LIMIT_PER_SECOND: i32 = 60;
fn join_room(&mut self, room_id: i32, id: usize) {
// remove session from all rooms
- for (_n, mut sessions) in &mut self.rooms {
+ for (_n, sessions) in &mut self.rooms {
sessions.remove(&id);
}
}
fn send_community_message(&self, community_id: &i32, message: &str, skip_id: usize) -> Result<(), Error> {
- use db::*;
- use db::post_view::*;
+ use crate::db::*;
+ use crate::db::post_view::*;
let conn = establish_connection();
let posts = PostView::list(&conn,
PostListingType::Community,