add: custom emojis
fix: don't show reposts of posts from blocked users fix: don't show questions when they're from users you've blocked
This commit is contained in:
parent
9f187039e6
commit
275dd0a1eb
25 changed files with 697 additions and 61 deletions
|
@ -78,7 +78,11 @@ impl DataManager {
|
|||
}
|
||||
|
||||
/// Get the post the given post is reposting (if some).
|
||||
pub async fn get_post_reposting(&self, post: &Post) -> Option<(User, Post)> {
|
||||
pub async fn get_post_reposting(
|
||||
&self,
|
||||
post: &Post,
|
||||
ignore_users: &[usize],
|
||||
) -> Option<(User, Post)> {
|
||||
if let Some(ref repost) = post.context.repost {
|
||||
if let Some(reposting) = repost.reposting {
|
||||
let mut x = match self.get_post_by_id(reposting).await {
|
||||
|
@ -86,6 +90,10 @@ impl DataManager {
|
|||
Err(_) => return None,
|
||||
};
|
||||
|
||||
if ignore_users.contains(&x.owner) {
|
||||
return None;
|
||||
}
|
||||
|
||||
x.mark_as_repost();
|
||||
Some((
|
||||
match self.get_user_by_id(x.owner).await {
|
||||
|
@ -103,9 +111,18 @@ impl DataManager {
|
|||
}
|
||||
|
||||
/// Get the question of a given post.
|
||||
pub async fn get_post_question(&self, post: &Post) -> Result<Option<(Question, User)>> {
|
||||
pub async fn get_post_question(
|
||||
&self,
|
||||
post: &Post,
|
||||
ignore_users: &[usize],
|
||||
) -> Result<Option<(Question, User)>> {
|
||||
if post.context.answering != 0 {
|
||||
let question = self.get_question_by_id(post.context.answering).await?;
|
||||
|
||||
if ignore_users.contains(&question.owner) {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let user = if question.owner == 0 {
|
||||
User::anonymous()
|
||||
} else {
|
||||
|
@ -138,8 +155,8 @@ impl DataManager {
|
|||
out.push((
|
||||
post.clone(),
|
||||
user.clone(),
|
||||
self.get_post_reposting(&post).await,
|
||||
self.get_post_question(&post).await?,
|
||||
self.get_post_reposting(&post, ignore_users).await,
|
||||
self.get_post_question(&post, ignore_users).await?,
|
||||
));
|
||||
} else {
|
||||
let user = self.get_user_by_id(owner).await?;
|
||||
|
@ -147,8 +164,8 @@ impl DataManager {
|
|||
out.push((
|
||||
post.clone(),
|
||||
user,
|
||||
self.get_post_reposting(&post).await,
|
||||
self.get_post_question(&post).await?,
|
||||
self.get_post_reposting(&post, ignore_users).await,
|
||||
self.get_post_question(&post, ignore_users).await?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -196,8 +213,8 @@ impl DataManager {
|
|||
post.clone(),
|
||||
user.clone(),
|
||||
community.to_owned(),
|
||||
self.get_post_reposting(&post).await,
|
||||
self.get_post_question(&post).await?,
|
||||
self.get_post_reposting(&post, ignore_users).await,
|
||||
self.get_post_question(&post, ignore_users).await?,
|
||||
));
|
||||
} else {
|
||||
let user = self.get_user_by_id(owner).await?;
|
||||
|
@ -235,8 +252,8 @@ impl DataManager {
|
|||
post.clone(),
|
||||
user,
|
||||
community,
|
||||
self.get_post_reposting(&post).await,
|
||||
self.get_post_question(&post).await?,
|
||||
self.get_post_reposting(&post, ignore_users).await,
|
||||
self.get_post_question(&post, ignore_users).await?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue