forked from jmug/stoatchat
refactor: clean up clippy warnings
This commit is contained in:
@@ -16,7 +16,7 @@ pub async fn fetch_public_bot(
|
||||
target: Reference,
|
||||
) -> Result<Json<PublicBot>> {
|
||||
let bot = db.fetch_bot(&target.id).await?;
|
||||
if !bot.public && user.map_or(true, |x| x.id != bot.owner) {
|
||||
if !bot.public && user.is_none_or(|x| x.id != bot.owner) {
|
||||
return Err(create_error!(NotFound));
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,8 @@ pub async fn message_send(
|
||||
// Create model user / members
|
||||
let model_user = user
|
||||
.clone()
|
||||
.into_known_static(revolt_presence::is_online(&user.id).await).await;
|
||||
.into_known_static(revolt_presence::is_online(&user.id).await)
|
||||
.await;
|
||||
|
||||
let model_member: Option<v0::Member> = query
|
||||
.member_ref()
|
||||
@@ -491,7 +492,7 @@ mod test {
|
||||
let (_, _, other_user) = harness.new_user().await;
|
||||
let (server, _) = harness.new_server(&user).await;
|
||||
let channel = harness.new_channel(&server).await;
|
||||
let (role_id, mut role) = harness
|
||||
let (role_id, _role) = harness
|
||||
.new_role(
|
||||
&server,
|
||||
1,
|
||||
|
||||
@@ -41,7 +41,7 @@ pub async fn call(
|
||||
// - If not, create it.
|
||||
let client = reqwest::Client::new();
|
||||
let result = client
|
||||
.get(&format!(
|
||||
.get(format!(
|
||||
"{}/room/{}",
|
||||
config.hosts.voso_legacy,
|
||||
channel.id()
|
||||
@@ -59,7 +59,7 @@ pub async fn call(
|
||||
reqwest::StatusCode::OK => (),
|
||||
reqwest::StatusCode::NOT_FOUND => {
|
||||
if (client
|
||||
.post(&format!(
|
||||
.post(format!(
|
||||
"{}/room/{}",
|
||||
config.hosts.voso_legacy,
|
||||
channel.id()
|
||||
@@ -81,7 +81,7 @@ pub async fn call(
|
||||
|
||||
// Then create a user for the room.
|
||||
if let Ok(response) = client
|
||||
.post(&format!(
|
||||
.post(format!(
|
||||
"{}/room/{}/user/{}",
|
||||
config.hosts.voso_legacy,
|
||||
channel.id(),
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
use revolt_database::{events::client::EventV1, Database, Report, Snapshot, SnapshotContent, User};
|
||||
use revolt_models::v0::{ReportStatus, ReportedContent};
|
||||
use revolt_result::{create_error, Result};
|
||||
use serde::Deserialize;
|
||||
use ulid::Ulid;
|
||||
use validator::Validate;
|
||||
use revolt_database::{Database, User};
|
||||
use revolt_result::Result;
|
||||
|
||||
use rocket::{serde::json::Json, State};
|
||||
use rocket::State;
|
||||
|
||||
/// # Acknowledge Policy Changes
|
||||
///
|
||||
|
||||
@@ -136,7 +136,6 @@ pub async fn root() -> Result<Json<RevoltConfig>> {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(feature = "FIXME: THIS TEST CAUSES cargo test TO SEG FAULT, I HAVE NO CLUE HOW")]
|
||||
mod test {
|
||||
use crate::rocket;
|
||||
use rocket::http::Status;
|
||||
|
||||
@@ -36,11 +36,11 @@ pub async fn webhook_execute(
|
||||
let permissions: PermissionValue = webhook.permissions.into();
|
||||
permissions.throw_if_lacking_channel_permission(ChannelPermission::SendMessage)?;
|
||||
|
||||
if data.attachments.as_ref().map_or(false, |v| !v.is_empty()) {
|
||||
if data.attachments.as_ref().is_some_and(|v| !v.is_empty()) {
|
||||
permissions.throw_if_lacking_channel_permission(ChannelPermission::UploadFiles)?;
|
||||
}
|
||||
|
||||
if data.embeds.as_ref().map_or(false, |v| !v.is_empty()) {
|
||||
if data.embeds.as_ref().is_some_and(|v| !v.is_empty()) {
|
||||
permissions.throw_if_lacking_channel_permission(ChannelPermission::SendEmbeds)?;
|
||||
}
|
||||
|
||||
|
||||
@@ -621,7 +621,7 @@ pub struct Event {
|
||||
#[derive(Debug, JsonSchema)]
|
||||
pub struct EventHeader<'r>(pub &'r str);
|
||||
|
||||
impl<'r> std::ops::Deref for EventHeader<'r> {
|
||||
impl std::ops::Deref for EventHeader<'_> {
|
||||
type Target = str;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
|
||||
@@ -109,8 +109,6 @@ fn resolve_bucket<'r>(request: &'r rocket::Request<'_>) -> (&'r str, Option<&'r
|
||||
};
|
||||
|
||||
if let Some(segment) = segment {
|
||||
let resource = resource;
|
||||
|
||||
let method = request.method();
|
||||
match (segment, resource, method) {
|
||||
("users", target, Method::Patch) => ("user_edit", target),
|
||||
@@ -254,7 +252,7 @@ impl<'r> FromRequest<'r> for Ratelimiter {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'r> OpenApiFromRequest<'r> for Ratelimiter {
|
||||
impl OpenApiFromRequest<'_> for Ratelimiter {
|
||||
fn from_request_input(
|
||||
_gen: &mut OpenApiGenerator,
|
||||
_name: String,
|
||||
|
||||
@@ -198,10 +198,7 @@ impl TestHarness {
|
||||
(channel.clone(), member, message)
|
||||
}
|
||||
|
||||
pub async fn with_session<'c>(
|
||||
session: Session,
|
||||
request: LocalRequest<'c>,
|
||||
) -> LocalResponse<'c> {
|
||||
pub async fn with_session(session: Session, request: LocalRequest<'_>) -> LocalResponse<'_> {
|
||||
request
|
||||
.header(Header::new("x-session-token", session.token.to_string()))
|
||||
.dispatch()
|
||||
|
||||
Reference in New Issue
Block a user