Browse Source

cargo fmt

feature/pictrs-v2.5
ryexandrite 2 years ago
parent
commit
a8ebbcf2c1
  1. 8
      server/lemmy_api_structs/src/comment.rs
  2. 26
      server/lemmy_db/src/comment.rs
  3. 5
      server/lemmy_db/src/moderator.rs
  4. 14
      server/lemmy_db/src/post.rs
  5. 6
      server/src/api/post.rs
  6. 13
      server/src/api/user.rs
  7. 2
      server/src/main.rs

8
server/lemmy_api_structs/src/comment.rs

@ -1,7 +1,9 @@
use lemmy_db::comment_view::CommentView;
use lemmy_db::{
comment_view::CommentView,
community_view::{CommunityModeratorView, CommunityView},
post_view::PostView,
};
use serde::{Deserialize, Serialize};
use lemmy_db::post_view::PostView;
use lemmy_db::community_view::{CommunityView, CommunityModeratorView};
#[derive(Serialize, Deserialize)]
pub struct GetComment {

26
server/lemmy_db/src/comment.rs

@ -201,20 +201,19 @@ impl Comment {
pub fn remove_user_comments(conn: &PgConnection, for_creator_id: i32) -> Result<Vec<i32>, Error> {
use crate::schema::comment::dsl::*;
diesel::update(comment
.filter(creator_id.eq(for_creator_id))
.filter(removed.eq(false))
diesel::update(
comment
.filter(creator_id.eq(for_creator_id))
.filter(removed.eq(false)),
)
.set((
removed.eq(true),
updated.eq(naive_now())
))
.returning(id)
.get_results(conn)
.set((removed.eq(true), updated.eq(naive_now())))
.returning(id)
.get_results(conn)
}
pub fn get_tree_ids(conn: &PgConnection, for_comment_id: i32) -> Result<Vec<CommentId>, Error> {
sql_query("
sql_query(
"
with recursive comment_tree as (
select id, parent_id, 1 AS depth
from comment
@ -228,9 +227,10 @@ impl Comment {
)
select id
from comment_tree
")
.bind::<Integer, _>(for_comment_id)
.load::<CommentId>(conn)
",
)
.bind::<Integer, _>(for_comment_id)
.load::<CommentId>(conn)
}
}

5
server/lemmy_db/src/moderator.rs

@ -185,7 +185,10 @@ impl Crud<ModRemoveCommentForm> for ModRemoveComment {
}
impl ModRemoveComment {
pub fn bulk_create(conn: &PgConnection, forms: &[ModRemoveCommentForm]) -> Result<Vec<Self>, Error> {
pub fn bulk_create(
conn: &PgConnection,
forms: &[ModRemoveCommentForm],
) -> Result<Vec<Self>, Error> {
use crate::schema::mod_remove_comment::dsl::*;
insert_into(mod_remove_comment)
.values(forms)

14
server/lemmy_db/src/post.rs

@ -222,16 +222,14 @@ impl Post {
pub fn remove_user_posts(conn: &PgConnection, for_creator_id: i32) -> Result<Vec<i32>, Error> {
use crate::schema::post::dsl::*;
diesel::update(post
diesel::update(
post
.filter(creator_id.eq(for_creator_id))
.filter(removed.eq(false))
.filter(removed.eq(false)),
)
.set((
removed.eq(true),
updated.eq(naive_now())
))
.returning(id)
.get_results(conn)
.set((removed.eq(true), updated.eq(naive_now())))
.returning(id)
.get_results(conn)
}
}

6
server/src/api/post.rs

@ -926,6 +926,8 @@ impl Perform for PostJoin {
});
}
Ok(PostJoinResponse { post_id: data.post_id })
Ok(PostJoinResponse {
post_id: data.post_id,
})
}
}
}

13
server/src/api/user.rs

@ -68,7 +68,14 @@ use crate::{
hcaptcha::hcaptcha_verify,
is_within_message_char_limit,
websocket::{
messages::{CaptchaItem, CheckCaptcha, JoinUserRoom, SendAllMessage, SendUserRoomMessage, LeaveAllRooms},
messages::{
CaptchaItem,
CheckCaptcha,
JoinUserRoom,
LeaveAllRooms,
SendAllMessage,
SendUserRoomMessage,
},
UserOperation,
},
LemmyContext,
@ -1668,9 +1675,7 @@ impl Perform for LeaveRooms {
websocket_id: Option<ConnectionId>,
) -> Result<LeaveRoomsResponse, LemmyError> {
if let Some(ws_id) = websocket_id {
context.chat_server().do_send(LeaveAllRooms {
id: ws_id,
});
context.chat_server().do_send(LeaveAllRooms { id: ws_id });
}
Ok(LeaveRoomsResponse { success: true })

2
server/src/main.rs

@ -4,6 +4,7 @@ extern crate diesel_migrations;
pub extern crate lazy_static;
use actix::prelude::*;
use actix_cors::Cors;
use actix_web::{
body::Body,
dev::{Service, ServiceRequest, ServiceResponse},
@ -31,7 +32,6 @@ use lemmy_utils::{settings::Settings, LemmyError, CACHE_CONTROL_REGEX};
use reqwest::Client;
use std::sync::Arc;
use tokio::sync::Mutex;
use actix_cors::Cors;
lazy_static! {
// static ref CACHE_CONTROL_VALUE: String = format!("public, max-age={}", 365 * 24 * 60 * 60);

Loading…
Cancel
Save