chore (backend-rs): remove unused derive

This commit is contained in:
naskya 2024-06-06 17:10:38 +09:00
parent fc590c1492
commit e9d31687f9
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
8 changed files with 39 additions and 30 deletions

View file

@ -7,7 +7,7 @@ use std::fs;
pub const VERSION: &str = macro_rs::read_version_from_package_json!();
#[derive(Clone, Debug, PartialEq, Deserialize)]
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
#[crate::export(object, use_nullable = false)]
struct ServerConfig {
@ -72,7 +72,7 @@ struct ServerConfig {
pub object_storage: Option<ObjectStorageConfig>,
}
#[derive(Clone, Debug, PartialEq, Deserialize)]
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
#[crate::export(object, use_nullable = false)]
pub struct DbConfig {
@ -85,7 +85,7 @@ pub struct DbConfig {
pub extra: Option<serde_json::Value>,
}
#[derive(Clone, Debug, PartialEq, Deserialize)]
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
#[crate::export(object, use_nullable = false)]
pub struct RedisConfig {
@ -100,7 +100,7 @@ pub struct RedisConfig {
pub prefix: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Deserialize)]
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
#[crate::export(object, use_nullable = false)]
pub struct TlsConfig {
@ -114,7 +114,7 @@ pub struct WorkerConfig {
pub queue: u32,
}
#[derive(Clone, Debug, PartialEq, Deserialize)]
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
#[crate::export(object, use_nullable = false)]
pub struct WorkerConfigInternal {
@ -122,7 +122,7 @@ pub struct WorkerConfigInternal {
pub queue: Option<u32>,
}
#[derive(Clone, Debug, PartialEq, Deserialize)]
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
#[crate::export(object, use_nullable = false)]
pub struct IdConfig {
@ -130,7 +130,7 @@ pub struct IdConfig {
pub fingerprint: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Deserialize)]
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
#[crate::export(object, use_nullable = false)]
pub struct SysLogConfig {
@ -138,7 +138,7 @@ pub struct SysLogConfig {
pub port: u16,
}
#[derive(Clone, Debug, PartialEq, Deserialize)]
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
#[crate::export(object, use_nullable = false)]
pub struct DeepLConfig {
@ -147,7 +147,7 @@ pub struct DeepLConfig {
pub is_pro: Option<bool>,
}
#[derive(Clone, Debug, PartialEq, Deserialize)]
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
#[crate::export(object, use_nullable = false)]
pub struct LibreTranslateConfig {
@ -156,7 +156,7 @@ pub struct LibreTranslateConfig {
pub api_key: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Deserialize)]
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
#[crate::export(object, use_nullable = false)]
pub struct EmailConfig {
@ -169,7 +169,7 @@ pub struct EmailConfig {
pub use_implicit_ssl_tls: Option<bool>,
}
#[derive(Clone, Debug, PartialEq, Deserialize)]
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
#[crate::export(object, use_nullable = false)]
pub struct ObjectStorageConfig {

View file

@ -1,7 +1,7 @@
use std::fmt;
use std::str::FromStr;
#[derive(Debug, PartialEq)]
#[cfg_attr(test, derive(Debug, PartialEq))]
#[crate::export(object)]
pub struct Acct {
pub username: String,

View file

@ -25,13 +25,13 @@ pub enum Error {
}
/// Represents the schema of `/.well-known/nodeinfo`.
#[derive(Deserialize, Debug)]
#[derive(Deserialize)]
pub struct NodeinfoLinks {
links: Vec<NodeinfoLink>,
}
/// Represents one entry of `/.well-known/nodeinfo`.
#[derive(Deserialize, Debug)]
#[derive(Deserialize)]
pub struct NodeinfoLink {
rel: String,
href: String,

View file

@ -10,7 +10,8 @@ use std::collections::HashMap;
// * #[serde(tag = "version", rename = "2.1")] (https://github.com/3Hren/msgpack-rust/issues/318)
/// NodeInfo schema version 2.1. <https://nodeinfo.diaspora.software/docson/index.html#/ns/schema/2.1>
#[derive(Deserialize, Serialize, Debug, PartialEq)]
#[cfg_attr(test, derive(Debug, PartialEq))]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Nodeinfo21 {
/// The schema version, must be 2.1.
@ -30,7 +31,8 @@ pub struct Nodeinfo21 {
}
/// NodeInfo schema version 2.0. <https://nodeinfo.diaspora.software/docson/index.html#/ns/schema/2.0>
#[derive(Deserialize, Serialize, Debug, PartialEq)]
#[cfg_attr(test, derive(Debug, PartialEq))]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
#[crate::export(object, js_name = "Nodeinfo")]
pub struct Nodeinfo20 {
@ -51,7 +53,8 @@ pub struct Nodeinfo20 {
}
/// Metadata about server software in use (version 2.1).
#[derive(Deserialize, Serialize, Debug, PartialEq)]
#[cfg_attr(test, derive(Debug, PartialEq))]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Software21 {
/// The canonical name of this server software.
@ -65,7 +68,8 @@ pub struct Software21 {
}
/// Metadata about server software in use (version 2.0).
#[derive(Deserialize, Serialize, Debug, PartialEq)]
#[cfg_attr(test, derive(Debug, PartialEq))]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
#[crate::export(object)]
pub struct Software20 {
@ -75,7 +79,8 @@ pub struct Software20 {
pub version: String,
}
#[derive(Deserialize, Serialize, Debug, PartialEq)]
#[cfg_attr(test, derive(Debug, PartialEq))]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
#[crate::export(string_enum = "lowercase")]
pub enum Protocol {
@ -92,7 +97,8 @@ pub enum Protocol {
}
/// The third party sites this server can connect to via their application API.
#[derive(Deserialize, Serialize, Debug, PartialEq)]
#[cfg_attr(test, derive(Debug, PartialEq))]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
#[crate::export(object)]
pub struct Services {
@ -103,7 +109,8 @@ pub struct Services {
}
/// The third party sites this server can retrieve messages from for combined display with regular traffic.
#[derive(Deserialize, Serialize, Debug, PartialEq)]
#[cfg_attr(test, derive(Debug, PartialEq))]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
#[crate::export(string_enum = "lowercase")]
pub enum Inbound {
@ -121,7 +128,8 @@ pub enum Inbound {
}
/// The third party sites this server can publish messages to on the behalf of a user.
#[derive(Deserialize, Serialize, Debug, PartialEq)]
#[cfg_attr(test, derive(Debug, PartialEq))]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
#[crate::export(string_enum = "lowercase")]
pub enum Outbound {
@ -158,7 +166,8 @@ pub enum Outbound {
}
/// Usage statistics for this server.
#[derive(Deserialize, Serialize, Debug, PartialEq)]
#[cfg_attr(test, derive(Debug, PartialEq))]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
#[crate::export(object)]
pub struct Usage {
@ -168,7 +177,8 @@ pub struct Usage {
}
/// statistics about the users of this server.
#[derive(Deserialize, Serialize, Debug, PartialEq)]
#[cfg_attr(test, derive(Debug, PartialEq))]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
#[crate::export(object)]
pub struct Users {

View file

@ -41,7 +41,7 @@ const BROWSER_SAFE_IMAGE_TYPES: [ImageFormat; 8] = [
static MTX_GUARD: Mutex<()> = Mutex::const_new(());
#[derive(Debug, PartialEq)]
#[cfg_attr(test, derive(Debug, PartialEq))]
#[crate::export(object)]
pub struct ImageSize {
pub width: u32,

View file

@ -1,6 +1,6 @@
use serde::Deserialize;
#[derive(Debug, Deserialize)]
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
#[crate::export(object)]
pub struct PartialNoteToSummarize {

View file

@ -6,7 +6,7 @@ use regex::Regex;
use sea_orm::prelude::*;
use std::collections::HashMap;
#[derive(PartialEq, Debug)]
#[cfg_attr(test, derive(PartialEq, Debug))]
#[crate::export(object)]
pub struct DecodedReaction {
pub reaction: String,

View file

@ -28,15 +28,14 @@ pub enum Error {
// for napi export
// https://github.com/napi-rs/napi-rs/issues/2060
type Antenna = antenna::Model;
type Note = note::Model;
// TODO?: it might be better to store this directly in memory
// (like fetch_meta) instead of Redis as it's used so much
async fn antennas() -> Result<Vec<Antenna>, Error> {
async fn antennas() -> Result<Vec<antenna::Model>, Error> {
const CACHE_KEY: &str = "antennas";
if let Some(antennas) = cache::get::<Vec<Antenna>>(CACHE_KEY).await? {
if let Some(antennas) = cache::get::<Vec<antenna::Model>>(CACHE_KEY).await? {
Ok(antennas)
} else {
let antennas = antenna::Entity::find().all(db_conn().await?).await?;