wip/kick #36

Merged
radical merged 9 commits from wip/kick into main 2025-07-22 16:56:37 +00:00
Member

Added the member endpoint, with a get and a delete(kick) request method

Added the member endpoint, with a get and a delete(kick) request method
baaboe added 3 commits 2025-07-22 15:40:08 +00:00
New endpoint 'members' with get and delete
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
82f4388dab
path name fix
Some checks failed
ci/woodpecker/push/build-and-publish Pipeline failed
4ec36c1cda
more path name fix
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
ci/woodpecker/pr/build-and-publish Pipeline was successful
228bc68327
radical requested changes 2025-07-22 15:54:46 +00:00
radical left a comment
Owner

Needs changes

Needs changes
@ -0,0 +10,4 @@
mod uuid;
pub fn router(app_state: Arc<AppState>) -> Router<Arc<AppState>> {
Owner

this router should not have a layer and merging it with an empty router is pointless here, function body should be written as:

Router::new()
        .route("/{uuid}", get(uuid::get))
        .route("/{uuid}", delete(uuid::delete))

and the function should not need the app_state parameter

this router should not have a layer and merging it with an empty router is pointless here, function body should be written as: ```rs Router::new() .route("/{uuid}", get(uuid::get)) .route("/{uuid}", delete(uuid::delete)) ``` and the function should not need the `app_state` parameter
radical marked this conversation as resolved
@ -0,0 +38,4 @@
State(app_state): State<Arc<AppState>>,
Path(member_uuid): Path<Uuid>,
Extension(CurrentUser(uuid)): Extension<CurrentUser<Uuid>>,
) -> Result<impl IntoResponse, Error> {
Owner

instead of calling app_state.pool.get().await? on multiple functions you should define it and use the same one multiple times

let mut conn = app_state.pool.get().await?;

let me = Me::get(&mut conn, uuid).await?;

let member = Member::fetch_one_with_member(&app_state, &me, member_uuid).await?;

let deleter = Member::check_membership(&mut conn, uuid, member.guild_uuid).await?;
    
deleter.check_permission(&app_state, Permissions::ManageMember).await?;

member.delete(&mut conn).await?;
instead of calling `app_state.pool.get().await?` on multiple functions you should define it and use the same one multiple times ```rs let mut conn = app_state.pool.get().await?; let me = Me::get(&mut conn, uuid).await?; let member = Member::fetch_one_with_member(&app_state, &me, member_uuid).await?; let deleter = Member::check_membership(&mut conn, uuid, member.guild_uuid).await?; deleter.check_permission(&app_state, Permissions::ManageMember).await?; member.delete(&mut conn).await?; ```
radical marked this conversation as resolved
@ -30,2 +31,3 @@
.nest("/auth", auth::router(app_state.clone()))
.nest("/channels", channels::router(app_state))
.nest("/channels", channels::router(app_state.clone()))
.nest("/member", member::router(app_state))
Owner

this should be moved to the router_with_auth instead as all endpoints inside /members needs auth, also it should be /members plural and not /member singular. This also goes for the folder/module name

this should be moved to the router_with_auth instead as all endpoints inside /members needs auth, also it should be `/members` plural and not `/member` singular. This also goes for the folder/module name
Author
Member

why plural, we are only accessing a single member

why plural, we are only accessing a single member
Owner

@baaboe wrote in #36 (comment):

why plural, we are only accessing a single member

Because it’s accessing a singular resource from the members resource collection. It’s a REST API thing.

@baaboe wrote in https://git.gorb.app/gorb/backend/pulls/36#issuecomment-831: > why plural, we are only accessing a single member Because it’s accessing a singular resource from the `members` resource *collection*. It’s a REST API thing.
Owner

/members contains all members, even though you're only accessing one, think of it like a folder tree with /members containing all of the members of every guild out there but you only have access to a subset of them

`/members` contains *all* members, even though you're only accessing one, think of it like a folder tree with /members containing all of the members of every guild out there but you only have access to a subset of them
radical marked this conversation as resolved
baaboe added 4 commits 2025-07-22 16:27:49 +00:00
radical reviewed 2025-07-22 16:28:38 +00:00
Owner

the get() function needs to check membership, missed it in the review. A user that is not a member of a server should not be able to view members of that server

the `get()` function needs to check membership, missed it in the review. A user that is not a member of a server should not be able to view members of that server
radical marked this conversation as resolved
baaboe added 1 commit 2025-07-22 16:33:54 +00:00
fix: Only people in a server should see its members list
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
ci/woodpecker/pr/build-and-publish Pipeline was successful
a3c460a611
baaboe added 1 commit 2025-07-22 16:50:29 +00:00
fix: cargo clippy --fix && cargo fmt
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
ci/woodpecker/pr/build-and-publish Pipeline was successful
ci/woodpecker/pull_request_closed/build-and-publish Pipeline was successful
c26ec49e05
radical merged commit 2996c6f108 into main 2025-07-22 16:56:37 +00:00
radical deleted branch wip/kick 2025-07-22 16:56:37 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: gorb/backend#36
No description provided.