add: manage followers page

This commit is contained in:
trisua 2025-07-15 00:08:49 -04:00
parent 959a125992
commit 70ecc6f96e
8 changed files with 119 additions and 6 deletions

View file

@ -154,6 +154,31 @@ pub async fn accept_follow_request(
}
}
pub async fn force_unfollow_me_request(
jar: CookieJar,
Path(id): Path<usize>,
Extension(data): Extension<State>,
) -> impl IntoResponse {
let data = &(data.read().await).0;
let user = match get_user_from_token!(jar, data, oauth::AppScope::UserManageFollowing) {
Some(ua) => ua,
None => return Json(Error::NotAllowed.into()),
};
if let Ok(userfollow) = data.get_userfollow_by_receiver_initiator(user.id, id).await {
match data.delete_userfollow(userfollow.id, &user, false).await {
Ok(_) => Json(ApiReturn {
ok: true,
message: "User is no longer following you".to_string(),
payload: (),
}),
Err(e) => Json(e.into()),
}
} else {
return Json(Error::GeneralNotFound("user follow".to_string()).into());
}
}
/// Toggle blocking on the given user.
pub async fn block_request(
jar: CookieJar,

View file

@ -293,6 +293,10 @@ pub fn routes() -> Router {
"/auth/user/{id}/follow/accept",
post(auth::social::accept_follow_request),
)
.route(
"/auth/user/{id}/force_unfollow_me",
post(auth::social::force_unfollow_me_request),
)
.route("/auth/user/{id}/block", post(auth::social::block_request))
.route(
"/auth/user/{id}/block_ip",