add: implement 9 new scopes, 21 new api endpoints
This commit is contained in:
parent
c3139ef1d2
commit
8f16068a34
14 changed files with 973 additions and 35 deletions
|
@ -292,6 +292,48 @@ macro_rules! check_user_blocked_or_private {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
($user:expr, $other_user:ident, $data:ident, @api) => {
|
||||
// check if we're blocked
|
||||
if let Some(ref ua) = $user {
|
||||
if $data
|
||||
.get_userblock_by_initiator_receiver($other_user.id, ua.id)
|
||||
.await
|
||||
.is_ok()
|
||||
&& !ua
|
||||
.permissions
|
||||
.check(tetratto_core::model::permissions::FinePermission::MANAGE_USERS)
|
||||
{
|
||||
return Json(
|
||||
tetratto_core::model::Error::MiscError("You're blocked".to_string()).into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 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(tetratto_core::model::permissions::FinePermission::MANAGE_USERS)
|
||||
&& $data
|
||||
.get_userfollow_by_initiator_receiver($other_user.id, ua.id)
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
return Json(
|
||||
tetratto_core::model::Error::MiscError("Profile is private".to_string())
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Json(
|
||||
tetratto_core::model::Error::MiscError("Profile is private".to_string()).into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
|
@ -318,4 +360,12 @@ macro_rules! ignore_users_gen {
|
|||
]
|
||||
.concat()
|
||||
};
|
||||
|
||||
($user:ident!, #$data:ident) => {
|
||||
[
|
||||
$data.get_userblocks_receivers($user.id).await,
|
||||
$data.get_userblocks_initiator_by_receivers($user.id).await,
|
||||
]
|
||||
.concat()
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue