add: manage followers page
This commit is contained in:
parent
959a125992
commit
70ecc6f96e
8 changed files with 119 additions and 6 deletions
|
@ -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,
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -63,11 +63,27 @@ pub async fn settings_request(
|
|||
}
|
||||
};
|
||||
|
||||
let followers = match data
|
||||
.0
|
||||
.fill_userfollows_with_initiator(
|
||||
data.0
|
||||
.get_userfollows_by_receiver(profile.id, 12, req.page)
|
||||
.await
|
||||
.unwrap_or(Vec::new()),
|
||||
&None,
|
||||
false,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(r) => r,
|
||||
Err(e) => return Err(Html(render_error(e, &jar, &data, &None).await)),
|
||||
};
|
||||
|
||||
let following = match data
|
||||
.0
|
||||
.fill_userfollows_with_receiver(
|
||||
data.0
|
||||
.get_userfollows_by_initiator_all(profile.id)
|
||||
.get_userfollows_by_initiator(profile.id, 12, req.page)
|
||||
.await
|
||||
.unwrap_or(Vec::new()),
|
||||
&None,
|
||||
|
@ -138,6 +154,7 @@ pub async fn settings_request(
|
|||
context.insert("page", &req.page);
|
||||
context.insert("uploads", &uploads);
|
||||
context.insert("stacks", &stacks);
|
||||
context.insert("followers", &followers);
|
||||
context.insert("following", &following);
|
||||
context.insert("blocks", &blocks);
|
||||
context.insert("stackblocks", &stackblocks);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue