|
|
@ -55,6 +55,7 @@ where
|
|
|
|
res
|
|
|
|
res
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(skip_all)]
|
|
|
|
pub async fn is_mod_or_admin(
|
|
|
|
pub async fn is_mod_or_admin(
|
|
|
|
pool: &DbPool,
|
|
|
|
pool: &DbPool,
|
|
|
|
person_id: PersonId,
|
|
|
|
person_id: PersonId,
|
|
|
@ -77,6 +78,7 @@ pub fn is_admin(local_user_view: &LocalUserView) -> Result<(), LemmyError> {
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(skip_all)]
|
|
|
|
pub async fn get_post(post_id: PostId, pool: &DbPool) -> Result<Post, LemmyError> {
|
|
|
|
pub async fn get_post(post_id: PostId, pool: &DbPool) -> Result<Post, LemmyError> {
|
|
|
|
blocking(pool, move |conn| Post::read(conn, post_id))
|
|
|
|
blocking(pool, move |conn| Post::read(conn, post_id))
|
|
|
|
.await?
|
|
|
|
.await?
|
|
|
@ -84,6 +86,7 @@ pub async fn get_post(post_id: PostId, pool: &DbPool) -> Result<Post, LemmyError
|
|
|
|
.map_err(|e| e.with_message("couldnt_find_post"))
|
|
|
|
.map_err(|e| e.with_message("couldnt_find_post"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(skip_all)]
|
|
|
|
pub async fn mark_post_as_read(
|
|
|
|
pub async fn mark_post_as_read(
|
|
|
|
person_id: PersonId,
|
|
|
|
person_id: PersonId,
|
|
|
|
post_id: PostId,
|
|
|
|
post_id: PostId,
|
|
|
@ -99,6 +102,7 @@ pub async fn mark_post_as_read(
|
|
|
|
.map_err(|e| e.with_message("couldnt_mark_post_as_read"))
|
|
|
|
.map_err(|e| e.with_message("couldnt_mark_post_as_read"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(skip_all)]
|
|
|
|
pub async fn mark_post_as_unread(
|
|
|
|
pub async fn mark_post_as_unread(
|
|
|
|
person_id: PersonId,
|
|
|
|
person_id: PersonId,
|
|
|
|
post_id: PostId,
|
|
|
|
post_id: PostId,
|
|
|
@ -114,6 +118,7 @@ pub async fn mark_post_as_unread(
|
|
|
|
.map_err(|e| e.with_message("couldnt_mark_post_as_read"))
|
|
|
|
.map_err(|e| e.with_message("couldnt_mark_post_as_read"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(skip_all)]
|
|
|
|
pub async fn get_local_user_view_from_jwt(
|
|
|
|
pub async fn get_local_user_view_from_jwt(
|
|
|
|
jwt: &str,
|
|
|
|
jwt: &str,
|
|
|
|
pool: &DbPool,
|
|
|
|
pool: &DbPool,
|
|
|
@ -154,6 +159,7 @@ pub fn check_validator_time(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(skip_all)]
|
|
|
|
pub async fn get_local_user_view_from_jwt_opt(
|
|
|
|
pub async fn get_local_user_view_from_jwt_opt(
|
|
|
|
jwt: Option<&Sensitive<String>>,
|
|
|
|
jwt: Option<&Sensitive<String>>,
|
|
|
|
pool: &DbPool,
|
|
|
|
pool: &DbPool,
|
|
|
@ -165,6 +171,7 @@ pub async fn get_local_user_view_from_jwt_opt(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(skip_all)]
|
|
|
|
pub async fn get_local_user_settings_view_from_jwt(
|
|
|
|
pub async fn get_local_user_settings_view_from_jwt(
|
|
|
|
jwt: &Sensitive<String>,
|
|
|
|
jwt: &Sensitive<String>,
|
|
|
|
pool: &DbPool,
|
|
|
|
pool: &DbPool,
|
|
|
@ -189,6 +196,7 @@ pub async fn get_local_user_settings_view_from_jwt(
|
|
|
|
Ok(local_user_view)
|
|
|
|
Ok(local_user_view)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(skip_all)]
|
|
|
|
pub async fn get_local_user_settings_view_from_jwt_opt(
|
|
|
|
pub async fn get_local_user_settings_view_from_jwt_opt(
|
|
|
|
jwt: Option<&Sensitive<String>>,
|
|
|
|
jwt: Option<&Sensitive<String>>,
|
|
|
|
pool: &DbPool,
|
|
|
|
pool: &DbPool,
|
|
|
@ -202,6 +210,7 @@ pub async fn get_local_user_settings_view_from_jwt_opt(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(skip_all)]
|
|
|
|
pub async fn check_community_ban(
|
|
|
|
pub async fn check_community_ban(
|
|
|
|
person_id: PersonId,
|
|
|
|
person_id: PersonId,
|
|
|
|
community_id: CommunityId,
|
|
|
|
community_id: CommunityId,
|
|
|
@ -216,6 +225,7 @@ pub async fn check_community_ban(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(skip_all)]
|
|
|
|
pub async fn check_community_deleted_or_removed(
|
|
|
|
pub async fn check_community_deleted_or_removed(
|
|
|
|
community_id: CommunityId,
|
|
|
|
community_id: CommunityId,
|
|
|
|
pool: &DbPool,
|
|
|
|
pool: &DbPool,
|
|
|
@ -239,6 +249,7 @@ pub fn check_post_deleted_or_removed(post: &Post) -> Result<(), LemmyError> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(skip_all)]
|
|
|
|
pub async fn check_person_block(
|
|
|
|
pub async fn check_person_block(
|
|
|
|
my_id: PersonId,
|
|
|
|
my_id: PersonId,
|
|
|
|
potential_blocker_id: PersonId,
|
|
|
|
potential_blocker_id: PersonId,
|
|
|
@ -252,6 +263,7 @@ pub async fn check_person_block(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(skip_all)]
|
|
|
|
pub async fn check_downvotes_enabled(score: i16, pool: &DbPool) -> Result<(), LemmyError> {
|
|
|
|
pub async fn check_downvotes_enabled(score: i16, pool: &DbPool) -> Result<(), LemmyError> {
|
|
|
|
if score == -1 {
|
|
|
|
if score == -1 {
|
|
|
|
let site = blocking(pool, Site::read_simple).await??;
|
|
|
|
let site = blocking(pool, Site::read_simple).await??;
|
|
|
@ -262,6 +274,7 @@ pub async fn check_downvotes_enabled(score: i16, pool: &DbPool) -> Result<(), Le
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(skip_all)]
|
|
|
|
pub async fn check_private_instance(
|
|
|
|
pub async fn check_private_instance(
|
|
|
|
local_user_view: &Option<LocalUserView>,
|
|
|
|
local_user_view: &Option<LocalUserView>,
|
|
|
|
pool: &DbPool,
|
|
|
|
pool: &DbPool,
|
|
|
@ -275,6 +288,7 @@ pub async fn check_private_instance(
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(skip_all)]
|
|
|
|
pub async fn build_federated_instances(
|
|
|
|
pub async fn build_federated_instances(
|
|
|
|
pool: &DbPool,
|
|
|
|
pool: &DbPool,
|
|
|
|
federation_config: &FederationConfig,
|
|
|
|
federation_config: &FederationConfig,
|
|
|
|