fix: don't allow mention spam

add: ip banning, ip ban management page
This commit is contained in:
trisua 2025-04-03 11:22:56 -04:00
parent 131a38abb9
commit e52733b00c
14 changed files with 260 additions and 15 deletions

View file

@ -33,6 +33,27 @@ pub async fn redirect_from_id(
}
}
pub async fn redirect_from_ip(
jar: CookieJar,
Extension(data): Extension<State>,
Path(ip): Path<String>,
) -> impl IntoResponse {
let data = &(data.read().await).0;
let user = match get_user_from_token!(jar, data) {
Some(ua) => ua,
None => return Redirect::to("/"),
};
if !user.permissions.check(FinePermission::MANAGE_BANS) {
return Redirect::to("/");
}
match data.get_user_by_token(&ip).await {
Ok(u) => Redirect::to(&format!("/@{}", u.username)),
Err(_) => Redirect::to("/"),
}
}
/// Update the settings of the given user.
pub async fn update_user_settings_request(
jar: CookieJar,

View file

@ -152,6 +152,10 @@ pub fn routes() -> Router {
"/auth/profile/find/{id}",
get(auth::profile::redirect_from_id),
)
.route(
"/auth/profile/find_by_ip/{ip}",
get(auth::profile::redirect_from_ip),
)
// notifications
.route(
"/notifications/my",