fix: improve generated openapi.json (#584)

* fix: /bots/{bot}

Paths "/bots/{bot}" and "/bots/{target}" must not be equivalent.

Signed-off-by: Damocles078 <hellodamocles078@gmail.com>

* fix: /channels/{group_id}/recipients/{member_id}

Paths "/channels/{group_id}/recipients/{member_id}" and "/channels/{target}/recipients/{member}" must not be equivalent.

Signed-off-by: Damocles078 <hellodamocles078@gmail.com>

* fix: /channels/{channel_id}/webhook

Paths "/channels/{target}/webhooks" and "/channels/{channel_id}/webhooks" must not be equivalent.

Signed-off-by: Damocles078 <hellodamocles078@gmail.com>

* fix: /servers/{server_id}/members/{member_id}

Paths "/servers/{target}/members/{member}" and "/servers/{server}/members/{member}" must not be equivalent.

Signed-off-by: Damocles078 <hellodamocles078@gmail.com>

* fix: /custom/emoji/{emoji_id}

Paths "/custom/emoji/{id}" and "/custom/emoji/{emoji_id}" must not be equivalent.

Signed-off-by: Damocles078 <hellodamocles078@gmail.com>

---------

Signed-off-by: Damocles078 <hellodamocles078@gmail.com>
Signed-off-by: Damocles <106018783+Damocles078@users.noreply.github.com>
This commit is contained in:
Damocles
2026-03-28 01:31:57 +01:00
committed by GitHub
parent c2d4369e16
commit 52ed5100c2
9 changed files with 43 additions and 43 deletions

View File

@@ -11,20 +11,20 @@ use rocket_empty::EmptyResponse;
///
/// Removes a user from the group.
#[openapi(tag = "Groups")]
#[delete("/<target>/recipients/<member>")]
#[delete("/<group_id>/recipients/<member_id>")]
pub async fn remove_member(
db: &State<Database>,
voice_client: &State<VoiceClient>,
amqp: &State<AMQP>,
user: User,
target: Reference<'_>,
member: Reference<'_>,
group_id: Reference<'_>,
member_id: Reference<'_>,
) -> Result<EmptyResponse> {
if user.bot.is_some() {
return Err(create_error!(IsBot));
}
let channel = target.as_channel(db).await?;
let channel = group_id.as_channel(db).await?;
if let Channel::Group {
owner, recipients, ..
@@ -36,7 +36,7 @@ pub async fn remove_member(
}));
}
let member = member.as_user(db).await?;
let member = member_id.as_user(db).await?;
if user.id == member.id {
return Err(create_error!(CannotRemoveYourself));
}
@@ -54,8 +54,8 @@ pub async fn remove_member(
let user_voice_channel = UserVoiceChannel::from_channel(&channel);
if is_in_voice_channel(member.id, &user_voice_channel).await? {
remove_user_from_voice_channel(voice_client, &user_voice_channel, member.id).await?;
if is_in_voice_channel(member_id.id, &user_voice_channel).await? {
remove_user_from_voice_channel(voice_client, &user_voice_channel, member_id.id).await?;
};
Ok(EmptyResponse)

View File

@@ -15,11 +15,11 @@ use validator::Validate;
///
/// Creates a webhook which 3rd party platforms can use to send messages
#[openapi(tag = "Webhooks")]
#[post("/<target>/webhooks", data = "<data>")]
#[post("/<channel_id>/webhooks", data = "<data>")]
pub async fn create_webhook(
db: &State<Database>,
user: User,
target: Reference<'_>,
channel_id: Reference<'_>,
data: Json<v0::CreateWebhookBody>,
) -> Result<Json<v0::Webhook>> {
let data = data.into_inner();
@@ -29,7 +29,7 @@ pub async fn create_webhook(
})
})?;
let channel = target.as_channel(db).await?;
let channel = channel_id.as_channel(db).await?;
if !matches!(channel, Channel::TextChannel { .. } | Channel::Group { .. }) {
return Err(create_error!(InvalidOperation));