chore: cleanup code

This commit is contained in:
Zomatree
2023-03-15 19:47:30 +00:00
parent 0321eff62b
commit f309218573
11 changed files with 11 additions and 29 deletions

View File

@@ -8,7 +8,7 @@ fn main() {
.output() .output()
{ {
if let Ok(git_origin) = String::from_utf8(output.stdout) { if let Ok(git_origin) = String::from_utf8(output.stdout) {
println!("cargo:rustc-env=GIT_ORIGIN_URL={}", git_origin); println!("cargo:rustc-env=GIT_ORIGIN_URL={git_origin}");
} }
} }

View File

@@ -11,20 +11,15 @@ use ulid::Ulid;
use validator::Validate; use validator::Validate;
/// # Channel Type /// # Channel Type
#[derive(Serialize, Deserialize, JsonSchema)] #[derive(Serialize, Deserialize, JsonSchema, Default)]
enum ChannelType { enum ChannelType {
/// Text Channel /// Text Channel
#[default]
Text, Text,
/// Voice Channel /// Voice Channel
Voice, Voice,
} }
impl Default for ChannelType {
fn default() -> Self {
ChannelType::Text
}
}
/// # Channel Data /// # Channel Data
#[derive(Validate, Serialize, Deserialize, JsonSchema)] #[derive(Validate, Serialize, Deserialize, JsonSchema)]
pub struct DataCreateChannel { pub struct DataCreateChannel {

View File

@@ -557,7 +557,7 @@ impl EventV1 {
/// Publish private event /// Publish private event
pub async fn private(self, id: String) { pub async fn private(self, id: String) {
self.p(format!("{}!", id)).await; self.p(format!("{id}!")).await;
} }
/// Publish internal global event /// Publish internal global event

View File

@@ -37,7 +37,7 @@ impl AbstractAttachment for MongoDb {
parent_type: &str, parent_type: &str,
parent_id: &str, parent_id: &str,
) -> Result<File> { ) -> Result<File> {
let key = format!("{}_id", parent_type); let key = format!("{parent_type}_id");
match self match self
.find_one::<File>( .find_one::<File>(
COL, COL,

View File

@@ -264,7 +264,7 @@ impl AbstractUser for MongoDb {
[ [
{ {
"_id": target_id, "_id": target_id,
"status": format!("{:?}", relationship) "status": format!("{relationship:?}")
} }
] ]
] ]

View File

@@ -157,10 +157,11 @@ pub struct Message {
/// # Message Sort /// # Message Sort
/// ///
/// Sort used for retrieving messages /// Sort used for retrieving messages
#[derive(Serialize, Deserialize, JsonSchema, Debug)] #[derive(Serialize, Deserialize, JsonSchema, Debug, Default)]
#[cfg_attr(feature = "rocket_impl", derive(FromFormField))] #[cfg_attr(feature = "rocket_impl", derive(FromFormField))]
pub enum MessageSort { pub enum MessageSort {
/// Sort by the most relevant messages /// Sort by the most relevant messages
#[default]
Relevance, Relevance,
/// Sort by the newest messages first /// Sort by the newest messages first
Latest, Latest,
@@ -168,12 +169,6 @@ pub enum MessageSort {
Oldest, Oldest,
} }
impl Default for MessageSort {
fn default() -> MessageSort {
MessageSort::Relevance
}
}
/// # Message Time Period /// # Message Time Period
/// ///
/// Filter and sort messages by time /// Filter and sort messages by time

View File

@@ -1,10 +1,11 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// Metadata associated with file /// Metadata associated with file
#[derive(Serialize, Deserialize, JsonSchema, Debug, Clone)] #[derive(Serialize, Deserialize, JsonSchema, Debug, Clone, Default)]
#[serde(tag = "type")] #[serde(tag = "type")]
pub enum Metadata { pub enum Metadata {
/// File is just a generic uncategorised file /// File is just a generic uncategorised file
#[default]
File, File,
/// File contains textual data and should be displayed as such /// File contains textual data and should be displayed as such
Text, Text,
@@ -16,12 +17,6 @@ pub enum Metadata {
Audio, Audio,
} }
impl Default for Metadata {
fn default() -> Metadata {
Metadata::File
}
}
/// Representation of a File on Revolt /// Representation of a File on Revolt
/// Generated by Autumn /// Generated by Autumn
#[derive(Serialize, Deserialize, JsonSchema, Debug, Clone, Default)] #[derive(Serialize, Deserialize, JsonSchema, Debug, Clone, Default)]

View File

@@ -2,7 +2,6 @@
use crate::Database; use crate::Database;
use deadqueue::limited::Queue; use deadqueue::limited::Queue;
use mongodb::bson::doc;
use std::{collections::HashMap, time::Duration}; use std::{collections::HashMap, time::Duration};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;

View File

@@ -2,7 +2,6 @@
use crate::{models::channel::PartialChannel, Database}; use crate::{models::channel::PartialChannel, Database};
use deadqueue::limited::Queue; use deadqueue::limited::Queue;
use mongodb::bson::doc;
use std::{collections::HashMap, time::Duration}; use std::{collections::HashMap, time::Duration};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;

View File

@@ -1,4 +1,3 @@
use crate::bson::doc;
use crate::util::variables::delta::VAPID_PRIVATE_KEY; use crate::util::variables::delta::VAPID_PRIVATE_KEY;
use authifier::Database; use authifier::Database;

View File

@@ -31,7 +31,7 @@ struct Entry {
reset: u128, reset: u128,
} }
static MAP: Lazy<DashMap<u64, Entry>> = Lazy::new(|| DashMap::new()); static MAP: Lazy<DashMap<u64, Entry>> = Lazy::new(DashMap::new);
/// Get the current time from Unix Epoch as a Duration /// Get the current time from Unix Epoch as a Duration
fn now() -> Duration { fn now() -> Duration {