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()
{
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;
/// # Channel Type
#[derive(Serialize, Deserialize, JsonSchema)]
#[derive(Serialize, Deserialize, JsonSchema, Default)]
enum ChannelType {
/// Text Channel
#[default]
Text,
/// Voice Channel
Voice,
}
impl Default for ChannelType {
fn default() -> Self {
ChannelType::Text
}
}
/// # Channel Data
#[derive(Validate, Serialize, Deserialize, JsonSchema)]
pub struct DataCreateChannel {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -31,7 +31,7 @@ struct Entry {
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
fn now() -> Duration {