add: implement 9 new scopes, 21 new api endpoints

This commit is contained in:
trisua 2025-06-13 17:47:00 -04:00
parent c3139ef1d2
commit 8f16068a34
14 changed files with 973 additions and 35 deletions

View file

@ -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()
};
}