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\"); console.log(\"socket disconnect\");
} }
} }
if (window.location.pathname.startsWith(\"/reference\")) {
window.location.reload();
}
}); });
</script> </script>
{%- endif %}") {%- endif %}")

View file

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

View file

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