Move send_local_notifs into lemmy_api_structs (ref #1115)
This commit is contained in:
parent
12109974c5
commit
d9e62f0886
32 changed files with 279 additions and 216 deletions
47
server/Cargo.lock
generated
vendored
47
server/Cargo.lock
generated
vendored
|
@ -139,12 +139,14 @@ dependencies = [
|
||||||
"actix-utils 2.0.0",
|
"actix-utils 2.0.0",
|
||||||
"base64 0.12.3",
|
"base64 0.12.3",
|
||||||
"bitflags 1.2.1",
|
"bitflags 1.2.1",
|
||||||
|
"brotli2",
|
||||||
"bytes",
|
"bytes",
|
||||||
"cookie",
|
"cookie",
|
||||||
"copyless",
|
"copyless",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
"either",
|
"either",
|
||||||
"encoding_rs",
|
"encoding_rs",
|
||||||
|
"flate2",
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
|
@ -698,6 +700,26 @@ dependencies = [
|
||||||
"opaque-debug 0.3.0",
|
"opaque-debug 0.3.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "brotli-sys"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4445dea95f4c2b41cde57cc9fee236ae4dbae88d8fcbdb4750fc1bb5d86aaecd"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "brotli2"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0cb036c3eade309815c15ddbacec5b22c4d1f3983a774ab2eac2e3e9ea85568e"
|
||||||
|
dependencies = [
|
||||||
|
"brotli-sys",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "buf-min"
|
name = "buf-min"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
|
@ -909,6 +931,15 @@ version = "0.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"
|
checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crc32fast"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-channel"
|
name = "crossbeam-channel"
|
||||||
version = "0.4.4"
|
version = "0.4.4"
|
||||||
|
@ -1258,6 +1289,18 @@ dependencies = [
|
||||||
"ascii_utils",
|
"ascii_utils",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "flate2"
|
||||||
|
version = "1.0.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "766d0e77a2c1502169d4a93ff3b8c15a71fd946cd0126309752104e5f3c46d94"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"crc32fast",
|
||||||
|
"libc",
|
||||||
|
"miniz_oxide",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fnv"
|
name = "fnv"
|
||||||
version = "1.0.7"
|
version = "1.0.7"
|
||||||
|
@ -1773,7 +1816,11 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
name = "lemmy_api_structs"
|
name = "lemmy_api_structs"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"actix-web",
|
||||||
|
"diesel",
|
||||||
"lemmy_db",
|
"lemmy_db",
|
||||||
|
"lemmy_utils",
|
||||||
|
"log",
|
||||||
"serde 1.0.115",
|
"serde 1.0.115",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
4
server/lemmy_api_structs/Cargo.toml
vendored
4
server/lemmy_api_structs/Cargo.toml
vendored
|
@ -10,4 +10,8 @@ path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lemmy_db = { path = "../lemmy_db" }
|
lemmy_db = { path = "../lemmy_db" }
|
||||||
|
lemmy_utils = { path = "../lemmy_utils" }
|
||||||
serde = { version = "1.0.105", features = ["derive"] }
|
serde = { version = "1.0.105", features = ["derive"] }
|
||||||
|
log = "0.4.0"
|
||||||
|
diesel = "1.4.4"
|
||||||
|
actix-web = { version = "3.0.0-alpha.3", features = ["rustls"] }
|
||||||
|
|
|
@ -1,7 +1,159 @@
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
|
extern crate log;
|
||||||
|
extern crate diesel;
|
||||||
|
extern crate actix_web;
|
||||||
|
|
||||||
pub mod comment;
|
pub mod comment;
|
||||||
pub mod community;
|
pub mod community;
|
||||||
pub mod post;
|
pub mod post;
|
||||||
pub mod site;
|
pub mod site;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
|
||||||
|
use lemmy_db::comment::Comment;
|
||||||
|
use lemmy_db::user::User_;
|
||||||
|
use lemmy_db::post::Post;
|
||||||
|
use lemmy_db::user_mention::{UserMentionForm, UserMention};
|
||||||
|
use log::error;
|
||||||
|
use lemmy_db::{Crud, DbPool};
|
||||||
|
use lemmy_utils::utils::MentionData;
|
||||||
|
use lemmy_utils::settings::Settings;
|
||||||
|
use lemmy_utils::email::send_email;
|
||||||
|
use diesel::PgConnection;
|
||||||
|
use lemmy_utils::LemmyError;
|
||||||
|
|
||||||
|
pub async fn blocking<F, T>(pool: &DbPool, f: F) -> Result<T, LemmyError>
|
||||||
|
where
|
||||||
|
F: FnOnce(&diesel::PgConnection) -> T + Send + 'static,
|
||||||
|
T: Send + 'static,
|
||||||
|
{
|
||||||
|
let pool = pool.clone();
|
||||||
|
let res = actix_web::web::block(move || {
|
||||||
|
let conn = pool.get()?;
|
||||||
|
let res = (f)(&conn);
|
||||||
|
Ok(res) as Result<_, LemmyError>
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_local_notifs(
|
||||||
|
mentions: Vec<MentionData>,
|
||||||
|
comment: Comment,
|
||||||
|
user: &User_,
|
||||||
|
post: Post,
|
||||||
|
pool: &DbPool,
|
||||||
|
do_send_email: bool,
|
||||||
|
) -> Result<Vec<i32>, LemmyError> {
|
||||||
|
let user2 = user.clone();
|
||||||
|
let ids = blocking(pool, move |conn| {
|
||||||
|
do_send_local_notifs(conn, &mentions, &comment, &user2, &post, do_send_email)
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(ids)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn do_send_local_notifs(
|
||||||
|
conn: &PgConnection,
|
||||||
|
mentions: &[MentionData],
|
||||||
|
comment: &Comment,
|
||||||
|
user: &User_,
|
||||||
|
post: &Post,
|
||||||
|
do_send_email: bool,
|
||||||
|
) -> Vec<i32> {
|
||||||
|
let mut recipient_ids = Vec::new();
|
||||||
|
let hostname = &format!("https://{}", Settings::get().hostname);
|
||||||
|
|
||||||
|
// Send the local mentions
|
||||||
|
for mention in mentions
|
||||||
|
.iter()
|
||||||
|
.filter(|m| m.is_local() && m.name.ne(&user.name))
|
||||||
|
.collect::<Vec<&MentionData>>()
|
||||||
|
{
|
||||||
|
if let Ok(mention_user) = User_::read_from_name(&conn, &mention.name) {
|
||||||
|
// TODO
|
||||||
|
// At some point, make it so you can't tag the parent creator either
|
||||||
|
// This can cause two notifications, one for reply and the other for mention
|
||||||
|
recipient_ids.push(mention_user.id);
|
||||||
|
|
||||||
|
let user_mention_form = UserMentionForm {
|
||||||
|
recipient_id: mention_user.id,
|
||||||
|
comment_id: comment.id,
|
||||||
|
read: None,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Allow this to fail softly, since comment edits might re-update or replace it
|
||||||
|
// Let the uniqueness handle this fail
|
||||||
|
match UserMention::create(&conn, &user_mention_form) {
|
||||||
|
Ok(_mention) => (),
|
||||||
|
Err(_e) => error!("{}", &_e),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Send an email to those users that have notifications on
|
||||||
|
if do_send_email && mention_user.send_notifications_to_email {
|
||||||
|
if let Some(mention_email) = mention_user.email {
|
||||||
|
let subject = &format!("{} - Mentioned by {}", Settings::get().hostname, user.name,);
|
||||||
|
let html = &format!(
|
||||||
|
"<h1>User Mention</h1><br><div>{} - {}</div><br><a href={}/inbox>inbox</a>",
|
||||||
|
user.name, comment.content, hostname
|
||||||
|
);
|
||||||
|
match send_email(subject, &mention_email, &mention_user.name, html) {
|
||||||
|
Ok(_o) => _o,
|
||||||
|
Err(e) => error!("{}", e),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send notifs to the parent commenter / poster
|
||||||
|
match comment.parent_id {
|
||||||
|
Some(parent_id) => {
|
||||||
|
if let Ok(parent_comment) = Comment::read(&conn, parent_id) {
|
||||||
|
if parent_comment.creator_id != user.id {
|
||||||
|
if let Ok(parent_user) = User_::read(&conn, parent_comment.creator_id) {
|
||||||
|
recipient_ids.push(parent_user.id);
|
||||||
|
|
||||||
|
if do_send_email && parent_user.send_notifications_to_email {
|
||||||
|
if let Some(comment_reply_email) = parent_user.email {
|
||||||
|
let subject = &format!("{} - Reply from {}", Settings::get().hostname, user.name,);
|
||||||
|
let html = &format!(
|
||||||
|
"<h1>Comment Reply</h1><br><div>{} - {}</div><br><a href={}/inbox>inbox</a>",
|
||||||
|
user.name, comment.content, hostname
|
||||||
|
);
|
||||||
|
match send_email(subject, &comment_reply_email, &parent_user.name, html) {
|
||||||
|
Ok(_o) => _o,
|
||||||
|
Err(e) => error!("{}", e),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Its a post
|
||||||
|
None => {
|
||||||
|
if post.creator_id != user.id {
|
||||||
|
if let Ok(parent_user) = User_::read(&conn, post.creator_id) {
|
||||||
|
recipient_ids.push(parent_user.id);
|
||||||
|
|
||||||
|
if do_send_email && parent_user.send_notifications_to_email {
|
||||||
|
if let Some(post_reply_email) = parent_user.email {
|
||||||
|
let subject = &format!("{} - Reply from {}", Settings::get().hostname, user.name,);
|
||||||
|
let html = &format!(
|
||||||
|
"<h1>Post Reply</h1><br><div>{} - {}</div><br><a href={}/inbox>inbox</a>",
|
||||||
|
user.name, comment.content, hostname
|
||||||
|
);
|
||||||
|
match send_email(subject, &post_reply_email, &parent_user.name, html) {
|
||||||
|
Ok(_o) => _o,
|
||||||
|
Err(e) => error!("{}", e),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
recipient_ids
|
||||||
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@ pub mod user_mention;
|
||||||
pub mod user_mention_view;
|
pub mod user_mention_view;
|
||||||
pub mod user_view;
|
pub mod user_view;
|
||||||
|
|
||||||
|
pub type DbPool = diesel::r2d2::Pool<diesel::r2d2::ConnectionManager<diesel::PgConnection>>;
|
||||||
|
|
||||||
pub trait Crud<T> {
|
pub trait Crud<T> {
|
||||||
fn create(conn: &PgConnection, form: &T) -> Result<Self, Error>
|
fn create(conn: &PgConnection, form: &T) -> Result<Self, Error>
|
||||||
where
|
where
|
||||||
|
|
|
@ -8,16 +8,14 @@ use crate::{
|
||||||
Perform,
|
Perform,
|
||||||
},
|
},
|
||||||
apub::{ApubLikeableType, ApubObjectType},
|
apub::{ApubLikeableType, ApubObjectType},
|
||||||
blocking,
|
|
||||||
websocket::{
|
websocket::{
|
||||||
messages::{JoinCommunityRoom, SendComment},
|
messages::{JoinCommunityRoom, SendComment},
|
||||||
UserOperation,
|
UserOperation,
|
||||||
},
|
},
|
||||||
DbPool,
|
|
||||||
LemmyContext,
|
LemmyContext,
|
||||||
};
|
};
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use lemmy_api_structs::comment::*;
|
use lemmy_api_structs::{blocking, comment::*, send_local_notifs};
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
comment::*,
|
comment::*,
|
||||||
comment_view::*,
|
comment_view::*,
|
||||||
|
@ -25,7 +23,6 @@ use lemmy_db::{
|
||||||
post::*,
|
post::*,
|
||||||
site_view::*,
|
site_view::*,
|
||||||
user::*,
|
user::*,
|
||||||
user_mention::*,
|
|
||||||
Crud,
|
Crud,
|
||||||
Likeable,
|
Likeable,
|
||||||
ListingType,
|
ListingType,
|
||||||
|
@ -34,14 +31,11 @@ use lemmy_db::{
|
||||||
};
|
};
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
apub::{make_apub_endpoint, EndpointType},
|
apub::{make_apub_endpoint, EndpointType},
|
||||||
email::send_email,
|
utils::{remove_slurs, scrape_text_for_mentions},
|
||||||
settings::Settings,
|
|
||||||
utils::{remove_slurs, scrape_text_for_mentions, MentionData},
|
|
||||||
APIError,
|
APIError,
|
||||||
ConnectionId,
|
ConnectionId,
|
||||||
LemmyError,
|
LemmyError,
|
||||||
};
|
};
|
||||||
use log::error;
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[async_trait::async_trait(?Send)]
|
#[async_trait::async_trait(?Send)]
|
||||||
|
@ -704,124 +698,3 @@ impl Perform for GetComments {
|
||||||
Ok(GetCommentsResponse { comments })
|
Ok(GetCommentsResponse { comments })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send_local_notifs(
|
|
||||||
mentions: Vec<MentionData>,
|
|
||||||
comment: Comment,
|
|
||||||
user: &User_,
|
|
||||||
post: Post,
|
|
||||||
pool: &DbPool,
|
|
||||||
do_send_email: bool,
|
|
||||||
) -> Result<Vec<i32>, LemmyError> {
|
|
||||||
let user2 = user.clone();
|
|
||||||
let ids = blocking(pool, move |conn| {
|
|
||||||
do_send_local_notifs(conn, &mentions, &comment, &user2, &post, do_send_email)
|
|
||||||
})
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(ids)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn do_send_local_notifs(
|
|
||||||
conn: &diesel::PgConnection,
|
|
||||||
mentions: &[MentionData],
|
|
||||||
comment: &Comment,
|
|
||||||
user: &User_,
|
|
||||||
post: &Post,
|
|
||||||
do_send_email: bool,
|
|
||||||
) -> Vec<i32> {
|
|
||||||
let mut recipient_ids = Vec::new();
|
|
||||||
let hostname = &format!("https://{}", Settings::get().hostname);
|
|
||||||
|
|
||||||
// Send the local mentions
|
|
||||||
for mention in mentions
|
|
||||||
.iter()
|
|
||||||
.filter(|m| m.is_local() && m.name.ne(&user.name))
|
|
||||||
.collect::<Vec<&MentionData>>()
|
|
||||||
{
|
|
||||||
if let Ok(mention_user) = User_::read_from_name(&conn, &mention.name) {
|
|
||||||
// TODO
|
|
||||||
// At some point, make it so you can't tag the parent creator either
|
|
||||||
// This can cause two notifications, one for reply and the other for mention
|
|
||||||
recipient_ids.push(mention_user.id);
|
|
||||||
|
|
||||||
let user_mention_form = UserMentionForm {
|
|
||||||
recipient_id: mention_user.id,
|
|
||||||
comment_id: comment.id,
|
|
||||||
read: None,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Allow this to fail softly, since comment edits might re-update or replace it
|
|
||||||
// Let the uniqueness handle this fail
|
|
||||||
match UserMention::create(&conn, &user_mention_form) {
|
|
||||||
Ok(_mention) => (),
|
|
||||||
Err(_e) => error!("{}", &_e),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Send an email to those users that have notifications on
|
|
||||||
if do_send_email && mention_user.send_notifications_to_email {
|
|
||||||
if let Some(mention_email) = mention_user.email {
|
|
||||||
let subject = &format!("{} - Mentioned by {}", Settings::get().hostname, user.name,);
|
|
||||||
let html = &format!(
|
|
||||||
"<h1>User Mention</h1><br><div>{} - {}</div><br><a href={}/inbox>inbox</a>",
|
|
||||||
user.name, comment.content, hostname
|
|
||||||
);
|
|
||||||
match send_email(subject, &mention_email, &mention_user.name, html) {
|
|
||||||
Ok(_o) => _o,
|
|
||||||
Err(e) => error!("{}", e),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send notifs to the parent commenter / poster
|
|
||||||
match comment.parent_id {
|
|
||||||
Some(parent_id) => {
|
|
||||||
if let Ok(parent_comment) = Comment::read(&conn, parent_id) {
|
|
||||||
if parent_comment.creator_id != user.id {
|
|
||||||
if let Ok(parent_user) = User_::read(&conn, parent_comment.creator_id) {
|
|
||||||
recipient_ids.push(parent_user.id);
|
|
||||||
|
|
||||||
if do_send_email && parent_user.send_notifications_to_email {
|
|
||||||
if let Some(comment_reply_email) = parent_user.email {
|
|
||||||
let subject = &format!("{} - Reply from {}", Settings::get().hostname, user.name,);
|
|
||||||
let html = &format!(
|
|
||||||
"<h1>Comment Reply</h1><br><div>{} - {}</div><br><a href={}/inbox>inbox</a>",
|
|
||||||
user.name, comment.content, hostname
|
|
||||||
);
|
|
||||||
match send_email(subject, &comment_reply_email, &parent_user.name, html) {
|
|
||||||
Ok(_o) => _o,
|
|
||||||
Err(e) => error!("{}", e),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Its a post
|
|
||||||
None => {
|
|
||||||
if post.creator_id != user.id {
|
|
||||||
if let Ok(parent_user) = User_::read(&conn, post.creator_id) {
|
|
||||||
recipient_ids.push(parent_user.id);
|
|
||||||
|
|
||||||
if do_send_email && parent_user.send_notifications_to_email {
|
|
||||||
if let Some(post_reply_email) = parent_user.email {
|
|
||||||
let subject = &format!("{} - Reply from {}", Settings::get().hostname, user.name,);
|
|
||||||
let html = &format!(
|
|
||||||
"<h1>Post Reply</h1><br><div>{} - {}</div><br><a href={}/inbox>inbox</a>",
|
|
||||||
user.name, comment.content, hostname
|
|
||||||
);
|
|
||||||
match send_email(subject, &post_reply_email, &parent_user.name, html) {
|
|
||||||
Ok(_o) => _o,
|
|
||||||
Err(e) => error!("{}", e),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
recipient_ids
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
api::{get_user_from_jwt, get_user_from_jwt_opt, is_admin, is_mod_or_admin, Perform},
|
api::{get_user_from_jwt, get_user_from_jwt_opt, is_admin, is_mod_or_admin, Perform},
|
||||||
apub::ActorType,
|
apub::ActorType,
|
||||||
blocking,
|
|
||||||
websocket::{
|
websocket::{
|
||||||
messages::{GetCommunityUsersOnline, JoinCommunityRoom, SendCommunityRoomMessage},
|
messages::{GetCommunityUsersOnline, JoinCommunityRoom, SendCommunityRoomMessage},
|
||||||
UserOperation,
|
UserOperation,
|
||||||
|
@ -10,7 +9,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use lemmy_api_structs::community::*;
|
use lemmy_api_structs::{blocking, community::*};
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
comment::Comment,
|
comment::Comment,
|
||||||
comment_view::CommentQueryBuilder,
|
comment_view::CommentQueryBuilder,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::{api::claims::Claims, blocking, DbPool, LemmyContext};
|
use crate::{api::claims::Claims, DbPool, LemmyContext};
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
|
use lemmy_api_structs::blocking;
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
community::Community,
|
community::Community,
|
||||||
community_view::CommunityUserBanView,
|
community_view::CommunityUserBanView,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
api::{check_community_ban, get_user_from_jwt, get_user_from_jwt_opt, is_mod_or_admin, Perform},
|
api::{check_community_ban, get_user_from_jwt, get_user_from_jwt_opt, is_mod_or_admin, Perform},
|
||||||
apub::{ApubLikeableType, ApubObjectType},
|
apub::{ApubLikeableType, ApubObjectType},
|
||||||
blocking,
|
|
||||||
fetch_iframely_and_pictrs_data,
|
fetch_iframely_and_pictrs_data,
|
||||||
websocket::{
|
websocket::{
|
||||||
messages::{GetPostUsersOnline, JoinCommunityRoom, JoinPostRoom, SendPost},
|
messages::{GetPostUsersOnline, JoinCommunityRoom, JoinPostRoom, SendPost},
|
||||||
|
@ -10,7 +9,7 @@ use crate::{
|
||||||
LemmyContext,
|
LemmyContext,
|
||||||
};
|
};
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use lemmy_api_structs::post::*;
|
use lemmy_api_structs::{blocking, post::*};
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
comment_view::*,
|
comment_view::*,
|
||||||
community_view::*,
|
community_view::*,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
api::{get_user_from_jwt, get_user_from_jwt_opt, is_admin, Perform},
|
api::{get_user_from_jwt, get_user_from_jwt_opt, is_admin, Perform},
|
||||||
apub::fetcher::search_by_apub_id,
|
apub::fetcher::search_by_apub_id,
|
||||||
blocking,
|
|
||||||
version,
|
version,
|
||||||
websocket::{
|
websocket::{
|
||||||
messages::{GetUsersOnline, SendAllMessage},
|
messages::{GetUsersOnline, SendAllMessage},
|
||||||
|
@ -11,7 +10,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use lemmy_api_structs::{site::*, user::Register};
|
use lemmy_api_structs::{blocking, site::*, user::Register};
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
category::*,
|
category::*,
|
||||||
comment_view::*,
|
comment_view::*,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
api::{claims::Claims, get_user_from_jwt, get_user_from_jwt_opt, is_admin, Perform},
|
api::{claims::Claims, get_user_from_jwt, get_user_from_jwt_opt, is_admin, Perform},
|
||||||
apub::ApubObjectType,
|
apub::ApubObjectType,
|
||||||
blocking,
|
|
||||||
captcha_espeak_wav_base64,
|
captcha_espeak_wav_base64,
|
||||||
websocket::{
|
websocket::{
|
||||||
messages::{CaptchaItem, CheckCaptcha, JoinUserRoom, SendAllMessage, SendUserRoomMessage},
|
messages::{CaptchaItem, CheckCaptcha, JoinUserRoom, SendAllMessage, SendUserRoomMessage},
|
||||||
|
@ -14,7 +13,7 @@ use anyhow::Context;
|
||||||
use bcrypt::verify;
|
use bcrypt::verify;
|
||||||
use captcha::{gen, Difficulty};
|
use captcha::{gen, Difficulty};
|
||||||
use chrono::Duration;
|
use chrono::Duration;
|
||||||
use lemmy_api_structs::user::*;
|
use lemmy_api_structs::{blocking, user::*};
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
comment::*,
|
comment::*,
|
||||||
comment_view::*,
|
comment_view::*,
|
||||||
|
|
|
@ -17,7 +17,6 @@ use crate::{
|
||||||
FromApub,
|
FromApub,
|
||||||
ToApub,
|
ToApub,
|
||||||
},
|
},
|
||||||
blocking,
|
|
||||||
DbPool,
|
DbPool,
|
||||||
LemmyContext,
|
LemmyContext,
|
||||||
};
|
};
|
||||||
|
@ -41,6 +40,7 @@ use activitystreams::{
|
||||||
use actix_web::{body::Body, web, web::Path, HttpResponse};
|
use actix_web::{body::Body, web, web::Path, HttpResponse};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
use lemmy_api_structs::blocking;
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
comment::{Comment, CommentForm},
|
comment::{Comment, CommentForm},
|
||||||
community::Community,
|
community::Community,
|
||||||
|
|
|
@ -14,7 +14,6 @@ use crate::{
|
||||||
GroupExt,
|
GroupExt,
|
||||||
ToApub,
|
ToApub,
|
||||||
},
|
},
|
||||||
blocking,
|
|
||||||
DbPool,
|
DbPool,
|
||||||
LemmyContext,
|
LemmyContext,
|
||||||
};
|
};
|
||||||
|
@ -39,6 +38,7 @@ use activitystreams_ext::Ext2;
|
||||||
use actix_web::{body::Body, web, HttpResponse};
|
use actix_web::{body::Body, web, HttpResponse};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
use lemmy_api_structs::blocking;
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
community::{Community, CommunityForm},
|
community::{Community, CommunityForm},
|
||||||
community_view::{CommunityFollowerView, CommunityModeratorView},
|
community_view::{CommunityFollowerView, CommunityModeratorView},
|
||||||
|
|
|
@ -8,7 +8,6 @@ use crate::{
|
||||||
PersonExt,
|
PersonExt,
|
||||||
APUB_JSON_CONTENT_TYPE,
|
APUB_JSON_CONTENT_TYPE,
|
||||||
},
|
},
|
||||||
blocking,
|
|
||||||
request::{retry, RecvError},
|
request::{retry, RecvError},
|
||||||
LemmyContext,
|
LemmyContext,
|
||||||
};
|
};
|
||||||
|
@ -16,7 +15,7 @@ use activitystreams::{base::BaseExt, collection::OrderedCollection, object::Note
|
||||||
use anyhow::{anyhow, Context};
|
use anyhow::{anyhow, Context};
|
||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
use diesel::result::Error::NotFound;
|
use diesel::result::Error::NotFound;
|
||||||
use lemmy_api_structs::site::SearchResponse;
|
use lemmy_api_structs::{blocking, site::SearchResponse};
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
comment::{Comment, CommentForm},
|
comment::{Comment, CommentForm},
|
||||||
comment_view::CommentView,
|
comment_view::CommentView,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
api::comment::send_local_notifs,
|
|
||||||
apub::{
|
apub::{
|
||||||
inbox::shared_inbox::{
|
inbox::shared_inbox::{
|
||||||
announce_if_community_is_local,
|
announce_if_community_is_local,
|
||||||
|
@ -10,7 +9,6 @@ use crate::{
|
||||||
FromApub,
|
FromApub,
|
||||||
PageExt,
|
PageExt,
|
||||||
},
|
},
|
||||||
blocking,
|
|
||||||
websocket::{
|
websocket::{
|
||||||
messages::{SendComment, SendPost},
|
messages::{SendComment, SendPost},
|
||||||
UserOperation,
|
UserOperation,
|
||||||
|
@ -20,7 +18,12 @@ use crate::{
|
||||||
use activitystreams::{activity::Create, base::AnyBase, object::Note, prelude::*};
|
use activitystreams::{activity::Create, base::AnyBase, object::Note, prelude::*};
|
||||||
use actix_web::HttpResponse;
|
use actix_web::HttpResponse;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use lemmy_api_structs::{comment::CommentResponse, post::PostResponse};
|
use lemmy_api_structs::{
|
||||||
|
blocking,
|
||||||
|
comment::CommentResponse,
|
||||||
|
post::PostResponse,
|
||||||
|
send_local_notifs,
|
||||||
|
};
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
comment::{Comment, CommentForm},
|
comment::{Comment, CommentForm},
|
||||||
comment_view::CommentView,
|
comment_view::CommentView,
|
||||||
|
|
|
@ -11,7 +11,6 @@ use crate::{
|
||||||
GroupExt,
|
GroupExt,
|
||||||
PageExt,
|
PageExt,
|
||||||
},
|
},
|
||||||
blocking,
|
|
||||||
websocket::{
|
websocket::{
|
||||||
messages::{SendComment, SendCommunityRoomMessage, SendPost},
|
messages::{SendComment, SendCommunityRoomMessage, SendPost},
|
||||||
UserOperation,
|
UserOperation,
|
||||||
|
@ -22,6 +21,7 @@ use activitystreams::{activity::Delete, base::AnyBase, object::Note, prelude::*}
|
||||||
use actix_web::HttpResponse;
|
use actix_web::HttpResponse;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use lemmy_api_structs::{
|
use lemmy_api_structs::{
|
||||||
|
blocking,
|
||||||
comment::CommentResponse,
|
comment::CommentResponse,
|
||||||
community::CommunityResponse,
|
community::CommunityResponse,
|
||||||
post::PostResponse,
|
post::PostResponse,
|
||||||
|
|
|
@ -9,7 +9,6 @@ use crate::{
|
||||||
FromApub,
|
FromApub,
|
||||||
PageExt,
|
PageExt,
|
||||||
},
|
},
|
||||||
blocking,
|
|
||||||
websocket::{
|
websocket::{
|
||||||
messages::{SendComment, SendPost},
|
messages::{SendComment, SendPost},
|
||||||
UserOperation,
|
UserOperation,
|
||||||
|
@ -19,7 +18,7 @@ use crate::{
|
||||||
use activitystreams::{activity::Dislike, base::AnyBase, object::Note, prelude::*};
|
use activitystreams::{activity::Dislike, base::AnyBase, object::Note, prelude::*};
|
||||||
use actix_web::HttpResponse;
|
use actix_web::HttpResponse;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use lemmy_api_structs::{comment::CommentResponse, post::PostResponse};
|
use lemmy_api_structs::{blocking, comment::CommentResponse, post::PostResponse};
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
comment::{CommentForm, CommentLike, CommentLikeForm},
|
comment::{CommentForm, CommentLike, CommentLikeForm},
|
||||||
comment_view::CommentView,
|
comment_view::CommentView,
|
||||||
|
|
|
@ -9,7 +9,6 @@ use crate::{
|
||||||
FromApub,
|
FromApub,
|
||||||
PageExt,
|
PageExt,
|
||||||
},
|
},
|
||||||
blocking,
|
|
||||||
websocket::{
|
websocket::{
|
||||||
messages::{SendComment, SendPost},
|
messages::{SendComment, SendPost},
|
||||||
UserOperation,
|
UserOperation,
|
||||||
|
@ -19,7 +18,7 @@ use crate::{
|
||||||
use activitystreams::{activity::Like, base::AnyBase, object::Note, prelude::*};
|
use activitystreams::{activity::Like, base::AnyBase, object::Note, prelude::*};
|
||||||
use actix_web::HttpResponse;
|
use actix_web::HttpResponse;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use lemmy_api_structs::{comment::CommentResponse, post::PostResponse};
|
use lemmy_api_structs::{blocking, comment::CommentResponse, post::PostResponse};
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
comment::{CommentForm, CommentLike, CommentLikeForm},
|
comment::{CommentForm, CommentLike, CommentLikeForm},
|
||||||
comment_view::CommentView,
|
comment_view::CommentView,
|
||||||
|
|
|
@ -12,7 +12,6 @@ use crate::{
|
||||||
GroupExt,
|
GroupExt,
|
||||||
PageExt,
|
PageExt,
|
||||||
},
|
},
|
||||||
blocking,
|
|
||||||
websocket::{
|
websocket::{
|
||||||
messages::{SendComment, SendCommunityRoomMessage, SendPost},
|
messages::{SendComment, SendCommunityRoomMessage, SendPost},
|
||||||
UserOperation,
|
UserOperation,
|
||||||
|
@ -23,6 +22,7 @@ use activitystreams::{activity::Remove, base::AnyBase, object::Note, prelude::*}
|
||||||
use actix_web::HttpResponse;
|
use actix_web::HttpResponse;
|
||||||
use anyhow::{anyhow, Context};
|
use anyhow::{anyhow, Context};
|
||||||
use lemmy_api_structs::{
|
use lemmy_api_structs::{
|
||||||
|
blocking,
|
||||||
comment::CommentResponse,
|
comment::CommentResponse,
|
||||||
community::CommunityResponse,
|
community::CommunityResponse,
|
||||||
post::PostResponse,
|
post::PostResponse,
|
||||||
|
|
|
@ -11,7 +11,6 @@ use crate::{
|
||||||
GroupExt,
|
GroupExt,
|
||||||
PageExt,
|
PageExt,
|
||||||
},
|
},
|
||||||
blocking,
|
|
||||||
websocket::{
|
websocket::{
|
||||||
messages::{SendComment, SendCommunityRoomMessage, SendPost},
|
messages::{SendComment, SendCommunityRoomMessage, SendPost},
|
||||||
UserOperation,
|
UserOperation,
|
||||||
|
@ -27,6 +26,7 @@ use activitystreams::{
|
||||||
use actix_web::HttpResponse;
|
use actix_web::HttpResponse;
|
||||||
use anyhow::{anyhow, Context};
|
use anyhow::{anyhow, Context};
|
||||||
use lemmy_api_structs::{
|
use lemmy_api_structs::{
|
||||||
|
blocking,
|
||||||
comment::CommentResponse,
|
comment::CommentResponse,
|
||||||
community::CommunityResponse,
|
community::CommunityResponse,
|
||||||
post::PostResponse,
|
post::PostResponse,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
api::comment::send_local_notifs,
|
|
||||||
apub::{
|
apub::{
|
||||||
fetcher::{get_or_fetch_and_insert_comment, get_or_fetch_and_insert_post},
|
fetcher::{get_or_fetch_and_insert_comment, get_or_fetch_and_insert_post},
|
||||||
inbox::shared_inbox::{
|
inbox::shared_inbox::{
|
||||||
|
@ -11,7 +10,6 @@ use crate::{
|
||||||
FromApub,
|
FromApub,
|
||||||
PageExt,
|
PageExt,
|
||||||
},
|
},
|
||||||
blocking,
|
|
||||||
websocket::{
|
websocket::{
|
||||||
messages::{SendComment, SendPost},
|
messages::{SendComment, SendPost},
|
||||||
UserOperation,
|
UserOperation,
|
||||||
|
@ -21,7 +19,12 @@ use crate::{
|
||||||
use activitystreams::{activity::Update, base::AnyBase, object::Note, prelude::*};
|
use activitystreams::{activity::Update, base::AnyBase, object::Note, prelude::*};
|
||||||
use actix_web::HttpResponse;
|
use actix_web::HttpResponse;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use lemmy_api_structs::{comment::CommentResponse, post::PostResponse};
|
use lemmy_api_structs::{
|
||||||
|
blocking,
|
||||||
|
comment::CommentResponse,
|
||||||
|
post::PostResponse,
|
||||||
|
send_local_notifs,
|
||||||
|
};
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
comment::{Comment, CommentForm},
|
comment::{Comment, CommentForm},
|
||||||
comment_view::CommentView,
|
comment_view::CommentView,
|
||||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
||||||
insert_activity,
|
insert_activity,
|
||||||
ActorType,
|
ActorType,
|
||||||
},
|
},
|
||||||
blocking,
|
|
||||||
LemmyContext,
|
LemmyContext,
|
||||||
};
|
};
|
||||||
use activitystreams::{
|
use activitystreams::{
|
||||||
|
@ -16,6 +15,7 @@ use activitystreams::{
|
||||||
};
|
};
|
||||||
use actix_web::{web, HttpRequest, HttpResponse};
|
use actix_web::{web, HttpRequest, HttpResponse};
|
||||||
use anyhow::{anyhow, Context};
|
use anyhow::{anyhow, Context};
|
||||||
|
use lemmy_api_structs::blocking;
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
community::{Community, CommunityFollower, CommunityFollowerForm},
|
community::{Community, CommunityFollower, CommunityFollowerForm},
|
||||||
user::User_,
|
user::User_,
|
||||||
|
|
|
@ -6,7 +6,6 @@ use crate::{
|
||||||
insert_activity,
|
insert_activity,
|
||||||
FromApub,
|
FromApub,
|
||||||
},
|
},
|
||||||
blocking,
|
|
||||||
websocket::{messages::SendUserRoomMessage, UserOperation},
|
websocket::{messages::SendUserRoomMessage, UserOperation},
|
||||||
LemmyContext,
|
LemmyContext,
|
||||||
};
|
};
|
||||||
|
@ -18,7 +17,7 @@ use activitystreams::{
|
||||||
};
|
};
|
||||||
use actix_web::{web, HttpRequest, HttpResponse};
|
use actix_web::{web, HttpRequest, HttpResponse};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use lemmy_api_structs::user::PrivateMessageResponse;
|
use lemmy_api_structs::{blocking, user::PrivateMessageResponse};
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
community::{CommunityFollower, CommunityFollowerForm},
|
community::{CommunityFollower, CommunityFollowerForm},
|
||||||
naive_now,
|
naive_now,
|
||||||
|
|
|
@ -15,7 +15,6 @@ use crate::{
|
||||||
page_extension::PageExtension,
|
page_extension::PageExtension,
|
||||||
signatures::{PublicKey, PublicKeyExtension},
|
signatures::{PublicKey, PublicKeyExtension},
|
||||||
},
|
},
|
||||||
blocking,
|
|
||||||
request::{retry, RecvError},
|
request::{retry, RecvError},
|
||||||
routes::webfinger::WebFingerResponse,
|
routes::webfinger::WebFingerResponse,
|
||||||
DbPool,
|
DbPool,
|
||||||
|
@ -33,6 +32,7 @@ use activitystreams_ext::{Ext1, Ext2};
|
||||||
use actix_web::{body::Body, HttpResponse};
|
use actix_web::{body::Body, HttpResponse};
|
||||||
use anyhow::{anyhow, Context};
|
use anyhow::{anyhow, Context};
|
||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
|
use lemmy_api_structs::blocking;
|
||||||
use lemmy_db::{activity::do_insert_activity, user::User_};
|
use lemmy_db::{activity::do_insert_activity, user::User_};
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
apub::get_apub_protocol_string,
|
apub::get_apub_protocol_string,
|
||||||
|
|
|
@ -14,7 +14,6 @@ use crate::{
|
||||||
PageExt,
|
PageExt,
|
||||||
ToApub,
|
ToApub,
|
||||||
},
|
},
|
||||||
blocking,
|
|
||||||
DbPool,
|
DbPool,
|
||||||
LemmyContext,
|
LemmyContext,
|
||||||
};
|
};
|
||||||
|
@ -36,6 +35,7 @@ use activitystreams::{
|
||||||
use activitystreams_ext::Ext1;
|
use activitystreams_ext::Ext1;
|
||||||
use actix_web::{body::Body, web, HttpResponse};
|
use actix_web::{body::Body, web, HttpResponse};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
use lemmy_api_structs::blocking;
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
community::Community,
|
community::Community,
|
||||||
post::{Post, PostForm},
|
post::{Post, PostForm},
|
||||||
|
|
|
@ -12,7 +12,6 @@ use crate::{
|
||||||
FromApub,
|
FromApub,
|
||||||
ToApub,
|
ToApub,
|
||||||
},
|
},
|
||||||
blocking,
|
|
||||||
DbPool,
|
DbPool,
|
||||||
LemmyContext,
|
LemmyContext,
|
||||||
};
|
};
|
||||||
|
@ -28,6 +27,7 @@ use activitystreams::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
use lemmy_api_structs::blocking;
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
private_message::{PrivateMessage, PrivateMessageForm},
|
private_message::{PrivateMessage, PrivateMessageForm},
|
||||||
user::User_,
|
user::User_,
|
||||||
|
|
|
@ -11,7 +11,6 @@ use crate::{
|
||||||
PersonExt,
|
PersonExt,
|
||||||
ToApub,
|
ToApub,
|
||||||
},
|
},
|
||||||
blocking,
|
|
||||||
DbPool,
|
DbPool,
|
||||||
LemmyContext,
|
LemmyContext,
|
||||||
};
|
};
|
||||||
|
@ -28,6 +27,7 @@ use activitystreams::{
|
||||||
use activitystreams_ext::Ext1;
|
use activitystreams_ext::Ext1;
|
||||||
use actix_web::{body::Body, web, HttpResponse};
|
use actix_web::{body::Body, web, HttpResponse};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
use lemmy_api_structs::blocking;
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
naive_now,
|
naive_now,
|
||||||
user::{UserForm, User_},
|
user::{UserForm, User_},
|
||||||
|
|
|
@ -36,6 +36,7 @@ use crate::{
|
||||||
use actix::Addr;
|
use actix::Addr;
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use background_jobs::QueueHandle;
|
use background_jobs::QueueHandle;
|
||||||
|
use lemmy_db::DbPool;
|
||||||
use lemmy_utils::{apub::get_apub_protocol_string, settings::Settings, LemmyError};
|
use lemmy_utils::{apub::get_apub_protocol_string, settings::Settings, LemmyError};
|
||||||
use log::error;
|
use log::error;
|
||||||
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
|
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
|
||||||
|
@ -43,8 +44,6 @@ use reqwest::Client;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
pub type DbPool = diesel::r2d2::Pool<diesel::r2d2::ConnectionManager<diesel::PgConnection>>;
|
|
||||||
|
|
||||||
pub struct LemmyContext {
|
pub struct LemmyContext {
|
||||||
pub pool: DbPool,
|
pub pool: DbPool,
|
||||||
pub chat_server: Addr<ChatServer>,
|
pub chat_server: Addr<ChatServer>,
|
||||||
|
@ -224,22 +223,6 @@ pub async fn is_image_content_type(client: &Client, test: &str) -> Result<(), Le
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn blocking<F, T>(pool: &DbPool, f: F) -> Result<T, LemmyError>
|
|
||||||
where
|
|
||||||
F: FnOnce(&diesel::PgConnection) -> T + Send + 'static,
|
|
||||||
T: Send + 'static,
|
|
||||||
{
|
|
||||||
let pool = pool.clone();
|
|
||||||
let res = actix_web::web::block(move || {
|
|
||||||
let conn = pool.get()?;
|
|
||||||
let res = (f)(&conn);
|
|
||||||
Ok(res) as Result<_, LemmyError>
|
|
||||||
})
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(res)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn captcha_espeak_wav_base64(captcha: &str) -> Result<String, LemmyError> {
|
pub fn captcha_espeak_wav_base64(captcha: &str) -> Result<String, LemmyError> {
|
||||||
let mut built_text = String::new();
|
let mut built_text = String::new();
|
||||||
|
|
||||||
|
|
|
@ -16,11 +16,11 @@ use diesel::{
|
||||||
PgConnection,
|
PgConnection,
|
||||||
};
|
};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
use lemmy_api_structs::blocking;
|
||||||
use lemmy_db::get_database_url_from_env;
|
use lemmy_db::get_database_url_from_env;
|
||||||
use lemmy_rate_limit::{rate_limiter::RateLimiter, RateLimit};
|
use lemmy_rate_limit::{rate_limiter::RateLimiter, RateLimit};
|
||||||
use lemmy_server::{
|
use lemmy_server::{
|
||||||
apub::activity_queue::create_activity_queue,
|
apub::activity_queue::create_activity_queue,
|
||||||
blocking,
|
|
||||||
code_migrations::run_advanced_migrations,
|
code_migrations::run_advanced_migrations,
|
||||||
routes::*,
|
routes::*,
|
||||||
websocket::chat_server::ChatServer,
|
websocket::chat_server::ChatServer,
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
use crate::{api::claims::Claims, blocking, LemmyContext};
|
use crate::{api::claims::Claims, LemmyContext};
|
||||||
use actix_web::{error::ErrorBadRequest, *};
|
use actix_web::{error::ErrorBadRequest, *};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||||
use diesel::PgConnection;
|
use diesel::PgConnection;
|
||||||
|
use lemmy_api_structs::blocking;
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
comment_view::{ReplyQueryBuilder, ReplyView},
|
comment_view::{ReplyQueryBuilder, ReplyView},
|
||||||
community::Community,
|
community::Community,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::{blocking, version, LemmyContext};
|
use crate::{version, LemmyContext};
|
||||||
use actix_web::{body::Body, error::ErrorBadRequest, *};
|
use actix_web::{body::Body, error::ErrorBadRequest, *};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
|
use lemmy_api_structs::blocking;
|
||||||
use lemmy_db::site_view::SiteView;
|
use lemmy_db::site_view::SiteView;
|
||||||
use lemmy_utils::{apub::get_apub_protocol_string, settings::Settings, LemmyError};
|
use lemmy_utils::{apub::get_apub_protocol_string, settings::Settings, LemmyError};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::{blocking, LemmyContext};
|
use crate::LemmyContext;
|
||||||
use actix_web::{error::ErrorBadRequest, web::Query, *};
|
use actix_web::{error::ErrorBadRequest, web::Query, *};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
|
use lemmy_api_structs::blocking;
|
||||||
use lemmy_db::{community::Community, user::User_};
|
use lemmy_db::{community::Community, user::User_};
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
settings::Settings,
|
settings::Settings,
|
||||||
|
|
Loading…
Reference in a new issue