add: allow users to block users who have blocked them/private users
fix: anonymous post page panic add: allow users to select home timeline
This commit is contained in:
parent
2460e2f8c5
commit
d42375441f
15 changed files with 313 additions and 122 deletions
|
@ -94,3 +94,85 @@ macro_rules! get_lang {
|
|||
}
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! check_user_blocked_or_private {
|
||||
($user:ident, $other_user:ident, $data:ident, $jar:ident) => {
|
||||
// check if we're blocked
|
||||
if let Some(ref ua) = $user {
|
||||
if $data
|
||||
.0
|
||||
.get_userblock_by_initiator_receiver($other_user.id, ua.id)
|
||||
.await
|
||||
.is_ok()
|
||||
{
|
||||
let lang = get_lang!($jar, $data.0);
|
||||
let mut context = initial_context(&$data.0.0, lang, &$user).await;
|
||||
|
||||
context.insert("profile", &$other_user);
|
||||
context.insert(
|
||||
"is_blocking",
|
||||
&$data
|
||||
.0
|
||||
.get_userblock_by_initiator_receiver(ua.id, $other_user.id)
|
||||
.await
|
||||
.is_ok(),
|
||||
);
|
||||
|
||||
return Ok(Html(
|
||||
$data.1.render("profile/blocked.html", &context).unwrap(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// check for private profile
|
||||
if $other_user.settings.private_profile {
|
||||
if let Some(ref ua) = $user {
|
||||
if (ua.id != $other_user.id)
|
||||
&& !ua.permissions.check(FinePermission::MANAGE_USERS)
|
||||
&& $data
|
||||
.0
|
||||
.get_userfollow_by_initiator_receiver($other_user.id, ua.id)
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
let lang = get_lang!($jar, $data.0);
|
||||
let mut context = initial_context(&$data.0.0, lang, &$user).await;
|
||||
|
||||
context.insert("profile", &$other_user);
|
||||
context.insert(
|
||||
"follow_requested",
|
||||
&$data
|
||||
.0
|
||||
.get_request_by_id_linked_asset(ua.id, $other_user.id)
|
||||
.await
|
||||
.is_ok(),
|
||||
);
|
||||
context.insert(
|
||||
"is_blocking",
|
||||
&$data
|
||||
.0
|
||||
.get_userblock_by_initiator_receiver(ua.id, $other_user.id)
|
||||
.await
|
||||
.is_ok(),
|
||||
);
|
||||
|
||||
return Ok(Html(
|
||||
$data.1.render("profile/private.html", &context).unwrap(),
|
||||
));
|
||||
}
|
||||
} else {
|
||||
let lang = get_lang!($jar, $data.0);
|
||||
let mut context = initial_context(&$data.0.0, lang, &$user).await;
|
||||
|
||||
context.insert("profile", &$other_user);
|
||||
context.insert("follow_requested", &false);
|
||||
context.insert("is_following", &false);
|
||||
|
||||
return Ok(Html(
|
||||
$data.1.render("profile/private.html", &context).unwrap(),
|
||||
));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue