add: hide_from_social_lists user setting
This commit is contained in:
parent
4e152b07be
commit
bdd8f9a869
5 changed files with 64 additions and 21 deletions
|
@ -195,18 +195,29 @@ impl DataManager {
|
|||
pub async fn fill_userfollows_with_receiver(
|
||||
&self,
|
||||
userfollows: Vec<UserFollow>,
|
||||
as_user: &Option<User>,
|
||||
do_check: bool,
|
||||
) -> Result<Vec<(UserFollow, User)>> {
|
||||
let mut out: Vec<(UserFollow, User)> = Vec::new();
|
||||
|
||||
for userfollow in userfollows {
|
||||
let receiver = userfollow.receiver;
|
||||
out.push((
|
||||
userfollow,
|
||||
match self.get_user_by_id(receiver).await {
|
||||
Ok(u) => u,
|
||||
Err(_) => continue,
|
||||
},
|
||||
));
|
||||
let user = match self.get_user_by_id(receiver).await {
|
||||
Ok(u) => u,
|
||||
Err(_) => continue,
|
||||
};
|
||||
|
||||
if user.settings.hide_from_social_lists && do_check {
|
||||
if let Some(ua) = as_user {
|
||||
if !ua.permissions.check(FinePermission::MANAGE_USERS) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
out.push((userfollow, user));
|
||||
}
|
||||
|
||||
Ok(out)
|
||||
|
@ -216,18 +227,29 @@ impl DataManager {
|
|||
pub async fn fill_userfollows_with_initiator(
|
||||
&self,
|
||||
userfollows: Vec<UserFollow>,
|
||||
as_user: &Option<User>,
|
||||
do_check: bool,
|
||||
) -> Result<Vec<(UserFollow, User)>> {
|
||||
let mut out: Vec<(UserFollow, User)> = Vec::new();
|
||||
|
||||
for userfollow in userfollows {
|
||||
let initiator = userfollow.initiator;
|
||||
out.push((
|
||||
userfollow,
|
||||
match self.get_user_by_id(initiator).await {
|
||||
Ok(u) => u,
|
||||
Err(_) => continue,
|
||||
},
|
||||
));
|
||||
let user = match self.get_user_by_id(initiator).await {
|
||||
Ok(u) => u,
|
||||
Err(_) => continue,
|
||||
};
|
||||
|
||||
if user.settings.hide_from_social_lists && do_check {
|
||||
if let Some(ua) = as_user {
|
||||
if !ua.permissions.check(FinePermission::MANAGE_USERS) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
out.push((userfollow, user));
|
||||
}
|
||||
|
||||
Ok(out)
|
||||
|
|
|
@ -302,6 +302,12 @@ pub struct UserSettings {
|
|||
/// Which tab is shown by default on the user's profile.
|
||||
#[serde(default)]
|
||||
pub default_profile_tab: DefaultProfileTabChoice,
|
||||
/// If the user is hidden from followers/following tabs.
|
||||
///
|
||||
/// The user will still impact the followers/following numbers, but will not
|
||||
/// be shown in the UI (or API).
|
||||
#[serde(default)]
|
||||
pub hide_from_social_lists: bool,
|
||||
}
|
||||
|
||||
fn mime_avif() -> String {
|
||||
|
@ -521,7 +527,7 @@ pub struct ExternalConnectionData {
|
|||
}
|
||||
|
||||
/// The total number of achievements needed to 100% Tetratto!
|
||||
pub const ACHIEVEMENTS: usize = 34;
|
||||
pub const ACHIEVEMENTS: usize = 36;
|
||||
/// "self-serve" achievements can be granted by the user through the API.
|
||||
pub const SELF_SERVE_ACHIEVEMENTS: &[AchievementName] = &[
|
||||
AchievementName::OpenReference,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue