Refactor handlers and OpenAPI documentation for improved readability and consistency
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 6m49s
test / unit (pull_request) Successful in 16m24s
test / integration (pull_request) Failing after 17m7s
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 6m49s
test / unit (pull_request) Successful in 16m24s
test / integration (pull_request) Failing after 17m7s
- Reorganized imports in health, notifications, social, thoughts, and users handlers for clarity. - Updated function signatures in handlers to improve readability by aligning parameters. - Enhanced JSON response formatting in notifications and thoughts handlers. - Improved error handling in user-related functions. - Refactored OpenAPI documentation to maintain consistent formatting and structure. - Cleaned up unnecessary code and comments across various files. - Ensured consistent use of `Arc` for shared state in AppState and WorkerHandlers.
This commit is contained in:
@@ -1,16 +1,29 @@
|
||||
use crate::value_objects::{Content, ThoughtId, UserId};
|
||||
use chrono::{DateTime, Utc};
|
||||
use crate::value_objects::{ThoughtId, UserId, Content};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub enum Visibility {
|
||||
Public, Followers, Unlisted, Direct,
|
||||
Public,
|
||||
Followers,
|
||||
Unlisted,
|
||||
Direct,
|
||||
}
|
||||
impl Visibility {
|
||||
pub fn from_str(s: &str) -> Self {
|
||||
match s { "followers" => Self::Followers, "unlisted" => Self::Unlisted, "direct" => Self::Direct, _ => Self::Public }
|
||||
match s {
|
||||
"followers" => Self::Followers,
|
||||
"unlisted" => Self::Unlisted,
|
||||
"direct" => Self::Direct,
|
||||
_ => Self::Public,
|
||||
}
|
||||
}
|
||||
pub fn as_str(&self) -> &str {
|
||||
match self { Self::Public => "public", Self::Followers => "followers", Self::Unlisted => "unlisted", Self::Direct => "direct" }
|
||||
match self {
|
||||
Self::Public => "public",
|
||||
Self::Followers => "followers",
|
||||
Self::Unlisted => "unlisted",
|
||||
Self::Direct => "direct",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,14 +45,27 @@ pub struct Thought {
|
||||
|
||||
impl Thought {
|
||||
pub fn new_local(
|
||||
id: ThoughtId, user_id: UserId, content: Content,
|
||||
in_reply_to_id: Option<ThoughtId>, visibility: Visibility,
|
||||
content_warning: Option<String>, sensitive: bool,
|
||||
id: ThoughtId,
|
||||
user_id: UserId,
|
||||
content: Content,
|
||||
in_reply_to_id: Option<ThoughtId>,
|
||||
visibility: Visibility,
|
||||
content_warning: Option<String>,
|
||||
sensitive: bool,
|
||||
) -> Self {
|
||||
Self {
|
||||
id, user_id, content, in_reply_to_id, in_reply_to_url: None, ap_id: None,
|
||||
visibility, content_warning, sensitive, local: true,
|
||||
created_at: Utc::now(), updated_at: None,
|
||||
id,
|
||||
user_id,
|
||||
content,
|
||||
in_reply_to_id,
|
||||
in_reply_to_url: None,
|
||||
ap_id: None,
|
||||
visibility,
|
||||
content_warning,
|
||||
sensitive,
|
||||
local: true,
|
||||
created_at: Utc::now(),
|
||||
updated_at: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user