pub async fn blocking<F, T>(pool: &DbPool, f: F) -> Result<T, LemmyError>
where
pub async fn blocking<F, T>(pool: &DbPool, f: F) -> Result<T, LemmyError>
where
T: Send + 'static,
{
let pool = pool.clone();
let blocking_span = tracing::info_span!("blocking operation");
actix_web::web::block(move || {
let entered = blocking_span.enter();
T: Send + 'static,
{
let pool = pool.clone();
let blocking_span = tracing::info_span!("blocking operation");
actix_web::web::block(move || {
let entered = blocking_span.enter();
if blocking(pool, is_banned).await? {
Err(LemmyError::from_message("community_ban"))
} else {
if blocking(pool, is_banned).await? {
Err(LemmyError::from_message("community_ban"))
} else {
potential_blocker_id: PersonId,
pool: &DbPool,
) -> Result<(), LemmyError> {
potential_blocker_id: PersonId,
pool: &DbPool,
) -> Result<(), LemmyError> {
if blocking(pool, is_blocked).await? {
Err(LemmyError::from_message("person_block"))
} else {
if blocking(pool, is_blocked).await? {
Err(LemmyError::from_message("person_block"))
} else {
settings: &Settings,
client: &ClientWithMiddleware,
) -> Result<(), LemmyError> {
settings: &Settings,
client: &ClientWithMiddleware,
) -> Result<(), LemmyError> {
settings: &Settings,
client: &ClientWithMiddleware,
) -> Result<(), LemmyError> {
settings: &Settings,
client: &ClientWithMiddleware,
) -> Result<(), LemmyError> {
Post::update_removed_for_creator(conn, banned_person_id, None, true)
})
.await??;
Post::update_removed_for_creator(conn, banned_person_id, None, true)
})
.await??;
// Communities
// Remove all communities where they're the top mod
// for now, remove the communities manually
// Communities
// Remove all communities where they're the top mod
// for now, remove the communities manually
for first_mod_community in banned_user_first_communities {
let community_id = first_mod_community.community.id;
for first_mod_community in banned_user_first_communities {
let community_id = first_mod_community.community.id;
blocking(pool, permadelete)
.await?
.map_err(|e| LemmyError::from_error_message(e, "couldnt_update_comment"))?;
// Posts
blocking(pool, permadelete)
.await?
.map_err(|e| LemmyError::from_error_message(e, "couldnt_update_comment"))?;
// Posts
blocking(pool, permadelete)
.await?
.map_err(|e| LemmyError::from_error_message(e, "couldnt_update_post"))?;
blocking(pool, permadelete)
.await?
.map_err(|e| LemmyError::from_error_message(e, "couldnt_update_post"))?;