add: user settings following page

add: comments to be seen by owner of the post they're on (even if the owner is private)
This commit is contained in:
trisua 2025-05-18 14:47:24 -04:00
parent fa1a609bf5
commit b8b0ef7f21
4 changed files with 154 additions and 7 deletions

View file

@ -21,6 +21,39 @@ use rusqlite::Row;
#[cfg(feature = "postgres")]
use tokio_postgres::Row;
macro_rules! private_post_replying {
($post:ident, $replying_posts:ident, $ua1:ident, $data:ident) => {
// post owner is not following us
// check if we're the owner of the post the post is replying to
// all routes but 1 must lead to continue
if let Some(replying) = $post.replying_to {
if replying != 0 {
if let Some(post) = $replying_posts.get(&replying) {
// we've seen this post before
if post.owner != $ua1.id {
// we aren't the owner of this post,
// so we can't see their comment
continue;
}
} else {
// we haven't seen this post before
let post = $data.get_post_by_id(replying).await?;
if post.owner != $ua1.id {
continue;
}
$replying_posts.insert(post.id, post);
}
} else {
continue;
}
} else {
continue;
}
};
}
impl DataManager {
/// Get a [`Post`] from an SQL row.
pub(crate) fn get_post_from_row(
@ -176,6 +209,7 @@ impl DataManager {
let mut users: HashMap<usize, User> = HashMap::new();
let mut seen_user_follow_statuses: HashMap<(usize, usize), bool> = HashMap::new();
let mut replying_posts: HashMap<usize, Post> = HashMap::new();
for post in posts {
if post.is_deleted {
@ -216,11 +250,10 @@ impl DataManager {
seen_user_follow_statuses.get(&(ua.id, ua1.id))
{
if !is_following
&& (ua.id != ua1.id)
&& ua.id != ua1.id
&& !ua1.permissions.check(FinePermission::MANAGE_POSTS)
{
// post owner is not following us
continue;
private_post_replying!(post, replying_posts, ua1, self);
}
} else {
if self
@ -228,10 +261,11 @@ impl DataManager {
.await
.is_err()
&& !ua1.permissions.check(FinePermission::MANAGE_POSTS)
&& ua.id != ua1.id
{
// post owner is not following us
seen_user_follow_statuses.insert((ua.id, ua1.id), false);
continue;
private_post_replying!(post, replying_posts, ua1, self);
}
seen_user_follow_statuses.insert((ua.id, ua1.id), true);