add: hide simple reposts you cannot view

quotes still show "Could not find original post..." when you cannot view the post that was quoted
This commit is contained in:
trisua 2025-06-16 18:32:22 -04:00
parent 844e60df30
commit a6aa2488c4
3 changed files with 66 additions and 21 deletions

View file

@ -53,6 +53,10 @@
console.log(\"socket disconnect\");
}
}
if (window.location.pathname.startsWith(\"/reference\")) {
window.location.reload();
}
});
</script>
{%- endif %}")

View file

@ -330,7 +330,7 @@
("class" "title")
(text "{{ text \"general:label.share\" }}"))
(button
("onclick" "trigger('me::repost', ['{{ post.id }}', '', '{{ config.town_square }}'])")
("onclick" "trigger('me::repost', ['{{ post.id }}', '', '{{ config.town_square }}', true])")
(text "{{ icon \"repeat-2\" }}")
(span
(text "{{ text \"communities:label.repost\" }}")))

View file

@ -158,26 +158,26 @@ impl DataManager {
post: &Post,
ignore_users: &[usize],
user: &Option<User>,
) -> Option<(User, Post)> {
) -> (bool, 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 {
Ok(p) => p,
Err(_) => return None,
Err(_) => return (true, None),
};
if x.is_deleted {
return None;
return (!post.content.is_empty(), None);
}
if ignore_users.contains(&x.owner) {
return None;
return (!post.content.is_empty(), None);
}
// check private profile settings
let owner = match self.get_user_by_id(x.owner).await {
Ok(ua) => ua,
Err(_) => return None,
Err(_) => return (true, None),
};
// TODO: maybe check community membership to see if we can MANAGE_POSTS in community
@ -191,29 +191,32 @@ impl DataManager {
.is_err()
{
// owner isn't following us, we aren't the owner, AND we don't have MANAGE_POSTS permission
return None;
return (!post.content.is_empty(), None);
}
}
} else {
// private profile, but we're an unauthenticated user
return None;
return (!post.content.is_empty(), None);
}
}
// ...
x.mark_as_repost();
Some((
match self.get_user_by_id(x.owner).await {
Ok(ua) => ua,
Err(_) => return None,
},
x,
))
(
true,
Some((
match self.get_user_by_id(x.owner).await {
Ok(ua) => ua,
Err(_) => return (true, None),
},
x,
)),
)
} else {
None
(true, None)
}
} else {
None
(true, None)
}
}
@ -340,6 +343,7 @@ impl DataManager {
let owner = post.owner;
if let Some(ua) = users.get(&owner) {
// stack
let (can_view, stack) = self
.get_post_stack(
&mut seen_stacks,
@ -352,10 +356,19 @@ impl DataManager {
continue;
}
// reposting
let (can_view, reposting) =
self.get_post_reposting(&post, ignore_users, user).await;
if !can_view {
continue;
}
// ...
out.push((
post.clone(),
ua.clone(),
self.get_post_reposting(&post, ignore_users, user).await,
reposting,
self.get_post_question(&post, ignore_users).await?,
self.get_post_poll(&post, user).await?,
stack,
@ -406,6 +419,7 @@ impl DataManager {
}
}
// stack
let (can_view, stack) = self
.get_post_stack(
&mut seen_stacks,
@ -418,12 +432,20 @@ impl DataManager {
continue;
}
// reposting
let (can_view, reposting) =
self.get_post_reposting(&post, ignore_users, user).await;
if !can_view {
continue;
}
// ...
users.insert(owner, ua.clone());
out.push((
post.clone(),
ua,
self.get_post_reposting(&post, ignore_users, user).await,
reposting,
self.get_post_question(&post, ignore_users).await?,
self.get_post_poll(&post, user).await?,
stack,
@ -458,6 +480,7 @@ impl DataManager {
let community = post.community;
if let Some((ua, community)) = seen_before.get(&(owner, community)) {
// stack
let (can_view, stack) = self
.get_post_stack(
&mut seen_stacks,
@ -470,11 +493,20 @@ impl DataManager {
continue;
}
// reposting
let (can_view, reposting) =
self.get_post_reposting(&post, ignore_users, user).await;
if !can_view {
continue;
}
// ...
out.push((
post.clone(),
ua.clone(),
community.to_owned(),
self.get_post_reposting(&post, ignore_users, user).await,
reposting,
self.get_post_question(&post, ignore_users).await?,
self.get_post_poll(&post, user).await?,
stack,
@ -516,6 +548,7 @@ impl DataManager {
}
}
// stack
let (can_view, stack) = self
.get_post_stack(
&mut seen_stacks,
@ -528,6 +561,14 @@ impl DataManager {
continue;
}
// reposting
let (can_view, reposting) =
self.get_post_reposting(&post, ignore_users, user).await;
if !can_view {
continue;
}
// ...
let community = self.get_community_by_id(community).await?;
seen_before.insert((owner, community.id), (ua.clone(), community.clone()));
@ -535,7 +576,7 @@ impl DataManager {
post.clone(),
ua,
community,
self.get_post_reposting(&post, ignore_users, user).await,
reposting,
self.get_post_question(&post, ignore_users).await?,
self.get_post_poll(&post, user).await?,
stack,