add: ability to require account to view profile
This commit is contained in:
parent
dd4f8b6d58
commit
741fe1c986
4 changed files with 74 additions and 35 deletions
|
@ -207,28 +207,31 @@ impl DataManager {
|
|||
continue;
|
||||
}
|
||||
|
||||
if let Some(is_following) = seen_user_follow_statuses.get(&(ua.id, ua1.id))
|
||||
{
|
||||
if !is_following
|
||||
&& (ua.id != ua1.id)
|
||||
&& !ua1.permissions.check(FinePermission::MANAGE_POSTS)
|
||||
if ua1.id != ua.id {
|
||||
if let Some(is_following) =
|
||||
seen_user_follow_statuses.get(&(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()
|
||||
&& !ua1.permissions.check(FinePermission::MANAGE_POSTS)
|
||||
{
|
||||
// post owner is not following us
|
||||
seen_user_follow_statuses.insert((ua.id, ua1.id), false);
|
||||
continue;
|
||||
}
|
||||
if !is_following
|
||||
&& (ua.id != ua1.id)
|
||||
&& !ua1.permissions.check(FinePermission::MANAGE_POSTS)
|
||||
{
|
||||
// post owner is not following us
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if self
|
||||
.get_userfollow_by_initiator_receiver(ua.id, ua1.id)
|
||||
.await
|
||||
.is_err()
|
||||
&& !ua1.permissions.check(FinePermission::MANAGE_POSTS)
|
||||
{
|
||||
// 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);
|
||||
seen_user_follow_statuses.insert((ua.id, ua1.id), true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// private post, but not authenticated
|
||||
|
@ -307,23 +310,26 @@ impl DataManager {
|
|||
continue;
|
||||
}
|
||||
|
||||
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(ua.id, user_id)
|
||||
.await
|
||||
.is_err()
|
||||
if user_id != ua.id {
|
||||
if let Some(is_following) = seen_user_follow_statuses.get(&(ua.id, user_id))
|
||||
{
|
||||
// post owner is not following us
|
||||
seen_user_follow_statuses.insert((ua.id, user_id), false);
|
||||
continue;
|
||||
}
|
||||
if !is_following && (ua.id != user_id) {
|
||||
// post owner is not following us
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if self
|
||||
.get_userfollow_by_initiator_receiver(ua.id, user_id)
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
// post owner is not following us
|
||||
seen_user_follow_statuses.insert((ua.id, user_id), false);
|
||||
continue;
|
||||
}
|
||||
|
||||
seen_user_follow_statuses.insert((ua.id, user_id), true);
|
||||
seen_user_follow_statuses.insert((ua.id, user_id), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1302,6 +1308,11 @@ impl DataManager {
|
|||
self.incr_question_answer_count(y.context.answering).await?;
|
||||
}
|
||||
}
|
||||
|
||||
// delete uploads
|
||||
for upload in y.uploads {
|
||||
self.delete_upload(upload).await?;
|
||||
}
|
||||
} else {
|
||||
// incr parent comment count
|
||||
if let Some(replying_to) = y.replying_to {
|
||||
|
@ -1323,6 +1334,8 @@ impl DataManager {
|
|||
self.decr_question_answer_count(y.context.answering).await?;
|
||||
}
|
||||
}
|
||||
|
||||
// unfortunately, uploads will not be restored
|
||||
}
|
||||
|
||||
// return
|
||||
|
|
|
@ -210,6 +210,9 @@ pub struct UserSettings {
|
|||
/// The mime type of the user's banner.
|
||||
#[serde(default = "mime_avif")]
|
||||
pub banner_mime: String,
|
||||
/// Require an account to view the user's profile.
|
||||
#[serde(default)]
|
||||
pub require_account: bool,
|
||||
}
|
||||
|
||||
fn mime_avif() -> String {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue