fix: don't show posts from private profiles when quoted

fix: password updating (mod)
This commit is contained in:
trisua 2025-05-15 23:59:26 -04:00
parent 2ec56809b8
commit 03b252937b
8 changed files with 87 additions and 36 deletions

View file

@ -387,7 +387,7 @@ impl DataManager {
force: bool,
) -> Result<()> {
// verify password
if (hash_salted(from.clone(), user.salt.clone()) != user.password) && !force {
if !user.check_password(from.clone()) && !force {
return Err(Error::MiscError("Password does not match".to_string()));
}

View file

@ -83,6 +83,7 @@ impl DataManager {
&self,
post: &Post,
ignore_users: &[usize],
user: &Option<User>,
) -> Option<(User, Post)> {
if let Some(ref repost) = post.context.repost {
if let Some(reposting) = repost.reposting {
@ -95,6 +96,30 @@ impl DataManager {
return None;
}
// check private profile settings
let owner = match self.get_user_by_id(x.owner).await {
Ok(ua) => ua,
Err(_) => return None,
};
if let Some(ua) = user {
// TODO: maybe check community membership to see if we can MANAGE_POSTS in community
if owner.settings.private_profile
&& owner.id != ua.id
&& !ua.permissions.check(FinePermission::MANAGE_POSTS)
{
if self
.get_userfollow_by_initiator_receiver(owner.id, ua.id)
.await
.is_err()
{
// owner isn't following us, we aren't the owner, AND we don't have MANAGE_POSTS permission
return None;
}
}
}
// ...
x.mark_as_repost();
Some((
match self.get_user_by_id(x.owner).await {
@ -141,6 +166,7 @@ impl DataManager {
&self,
posts: Vec<Post>,
ignore_users: &[usize],
user: &Option<User>,
) -> Result<Vec<(Post, User, Option<(User, Post)>, Option<(Question, User)>)>> {
let mut out: Vec<(Post, User, Option<(User, Post)>, Option<(Question, User)>)> = Vec::new();
@ -152,20 +178,20 @@ impl DataManager {
continue;
}
if let Some(user) = users.get(&owner) {
if let Some(ua) = users.get(&owner) {
out.push((
post.clone(),
user.clone(),
self.get_post_reposting(&post, ignore_users).await,
ua.clone(),
self.get_post_reposting(&post, ignore_users, user).await,
self.get_post_question(&post, ignore_users).await?,
));
} else {
let user = self.get_user_by_id(owner).await?;
users.insert(owner, user.clone());
let ua = self.get_user_by_id(owner).await?;
users.insert(owner, ua.clone());
out.push((
post.clone(),
user,
self.get_post_reposting(&post, ignore_users).await,
ua,
self.get_post_reposting(&post, ignore_users, user).await,
self.get_post_question(&post, ignore_users).await?,
));
}
@ -180,6 +206,7 @@ impl DataManager {
posts: Vec<Post>,
user_id: usize,
ignore_users: &[usize],
user: &Option<User>,
) -> Result<
Vec<(
Post,
@ -209,51 +236,51 @@ impl DataManager {
let community = post.community;
if let Some((user, community)) = seen_before.get(&(owner, community)) {
if let Some((ua, community)) = seen_before.get(&(owner, community)) {
out.push((
post.clone(),
user.clone(),
ua.clone(),
community.to_owned(),
self.get_post_reposting(&post, ignore_users).await,
self.get_post_reposting(&post, ignore_users, user).await,
self.get_post_question(&post, ignore_users).await?,
));
} else {
let user = self.get_user_by_id(owner).await?;
let ua = self.get_user_by_id(owner).await?;
// check relationship
if user.settings.private_profile && user.id != user_id {
if ua.settings.private_profile && ua.id != user_id {
if user_id == 0 {
continue;
}
if let Some(is_following) = seen_user_follow_statuses.get(&(user.id, user_id)) {
if !is_following && (user.id != user_id) {
if let Some(is_following) = seen_user_follow_statuses.get(&(ua.id, user_id)) {
if !is_following && (ua.id != user_id) {
// post owner is not following us
continue;
}
} else {
if self
.get_userfollow_by_initiator_receiver(user.id, user_id)
.get_userfollow_by_initiator_receiver(ua.id, user_id)
.await
.is_err()
{
// post owner is not following us
seen_user_follow_statuses.insert((user.id, user_id), false);
seen_user_follow_statuses.insert((ua.id, user_id), false);
continue;
}
seen_user_follow_statuses.insert((user.id, user_id), true);
seen_user_follow_statuses.insert((ua.id, user_id), true);
}
}
// ...
let community = self.get_community_by_id(community).await?;
seen_before.insert((owner, community.id), (user.clone(), community.clone()));
seen_before.insert((owner, community.id), (ua.clone(), community.clone()));
out.push((
post.clone(),
user,
ua,
community,
self.get_post_reposting(&post, ignore_users).await,
self.get_post_reposting(&post, ignore_users, user).await,
self.get_post_question(&post, ignore_users).await?,
));
}

View file

@ -43,6 +43,7 @@ impl DataManager {
batch: usize,
page: usize,
ignore_users: &Vec<usize>,
user: &Option<User>,
) -> Result<
Vec<(
Post,
@ -61,6 +62,7 @@ impl DataManager {
.await?,
as_user_id,
ignore_users,
user,
)
.await?
}
@ -73,6 +75,7 @@ impl DataManager {
self.get_latest_posts(batch, page).await?,
as_user_id,
&ignore_users,
user,
)
.await?
}
@ -81,6 +84,7 @@ impl DataManager {
self.get_popular_posts(batch, page, 604_800_000).await?,
as_user_id,
&ignore_users,
user,
)
.await?
}