add: show if user account is banned on profile
fix: check post owner privacy settings on community pages
This commit is contained in:
parent
03b252937b
commit
4c26879d00
9 changed files with 112 additions and 14 deletions
|
@ -102,20 +102,23 @@ impl DataManager {
|
|||
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()
|
||||
// TODO: maybe check community membership to see if we can MANAGE_POSTS in community
|
||||
if owner.settings.private_profile {
|
||||
if let Some(ua) = user {
|
||||
if owner.id != ua.id && !ua.permissions.check(FinePermission::MANAGE_POSTS)
|
||||
{
|
||||
// owner isn't following us, we aren't the owner, AND we don't have MANAGE_POSTS permission
|
||||
return None;
|
||||
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;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// private profile, but we're an unauthenticated user
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,6 +174,8 @@ impl DataManager {
|
|||
let mut out: Vec<(Post, User, Option<(User, Post)>, Option<(Question, User)>)> = Vec::new();
|
||||
|
||||
let mut users: HashMap<usize, User> = HashMap::new();
|
||||
let mut seen_user_follow_statuses: HashMap<(usize, usize), bool> = HashMap::new();
|
||||
|
||||
for post in posts {
|
||||
let owner = post.owner;
|
||||
|
||||
|
@ -187,6 +192,40 @@ impl DataManager {
|
|||
));
|
||||
} else {
|
||||
let ua = self.get_user_by_id(owner).await?;
|
||||
|
||||
// check relationship
|
||||
if ua.settings.private_profile {
|
||||
if let Some(ua1) = user {
|
||||
if ua1.id == 0 {
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Some(is_following) = seen_user_follow_statuses.get(&(ua.id, ua1.id))
|
||||
{
|
||||
if !is_following && (ua.id != ua1.id) {
|
||||
// post owner is not following us
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if self
|
||||
.get_userfollow_by_initiator_receiver(ua.id, ua1.id)
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
// post owner is not following us
|
||||
seen_user_follow_statuses.insert((ua.id, ua1.id), false);
|
||||
continue;
|
||||
}
|
||||
|
||||
seen_user_follow_statuses.insert((ua.id, ua1.id), true);
|
||||
}
|
||||
} else {
|
||||
// private post, but not authenticated
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// ...
|
||||
users.insert(owner, ua.clone());
|
||||
out.push((
|
||||
post.clone(),
|
||||
|
|
|
@ -35,6 +35,7 @@ bitflags! {
|
|||
const MANAGE_UPLOADS = 1 << 24;
|
||||
const MANAGE_EMOJIS = 1 << 25;
|
||||
const MANAGE_STACKS = 1 << 26;
|
||||
const STAFF_BADGE = 1 << 27;
|
||||
|
||||
const _ = !0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue