},
Crud,
DbPool,
+ Readable,
};
use lemmy_db_schema::{
source::{
community::{Community, CommunityModerator},
person::Person,
person_mention::{PersonMention, PersonMentionForm},
- post::Post,
+ post::{Post, PostRead, PostReadForm},
site::Site,
},
CommunityId,
Ok(())
}
-/// A helper method for showing the bot account
-pub fn user_show_bot_accounts(local_user_view: &Option<LocalUserView>) -> bool {
- match local_user_view {
- Some(uv) => uv.to_owned().local_user.show_bot_accounts,
- None => true,
- }
-}
-
-/// A helper method for showing nsfw
-pub fn user_show_nsfw(local_user_view: &Option<LocalUserView>) -> bool {
- match &local_user_view {
- Some(uv) => uv.local_user.show_nsfw,
- None => false,
- }
-}
-
pub async fn get_post(post_id: PostId, pool: &DbPool) -> Result<Post, LemmyError> {
blocking(pool, move |conn| Post::read(conn, post_id))
.await?
.map_err(|_| ApiError::err("couldnt_find_post").into())
}
+pub async fn mark_post_as_read(
+ person_id: PersonId,
+ post_id: PostId,
+ pool: &DbPool,
+) -> Result<PostRead, LemmyError> {
+ let post_read_form = PostReadForm { post_id, person_id };
+
+ blocking(pool, move |conn| {
+ PostRead::mark_as_read(conn, &post_read_form)
+ })
+ .await?
+ .map_err(|_| ApiError::err("couldnt_mark_post_as_read").into())
+}
+
pub async fn get_local_user_view_from_jwt(
jwt: &str,
pool: &DbPool,