various: simplify code; work on security and performance
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I9a5114addcab5fbff430ab2b919b83466a6a6964
This commit is contained in:
parent
016841b200
commit
c4adc4e3e0
75 changed files with 12921 additions and 358 deletions
52
crates/pinakes-core/src/social.rs
Normal file
52
crates/pinakes-core/src/social.rs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
//! Social features: ratings, comments, favorites, and share links.
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::model::MediaId;
|
||||
use crate::users::UserId;
|
||||
|
||||
/// A user's rating for a media item.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Rating {
|
||||
pub id: Uuid,
|
||||
pub user_id: UserId,
|
||||
pub media_id: MediaId,
|
||||
pub stars: u8,
|
||||
pub review_text: Option<String>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
/// A comment on a media item, supporting threaded replies.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Comment {
|
||||
pub id: Uuid,
|
||||
pub user_id: UserId,
|
||||
pub media_id: MediaId,
|
||||
pub parent_comment_id: Option<Uuid>,
|
||||
pub text: String,
|
||||
pub created_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
/// A user's favorite bookmark for a media item.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Favorite {
|
||||
pub user_id: UserId,
|
||||
pub media_id: MediaId,
|
||||
pub created_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
/// A shareable link to a media item with optional password and expiration.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ShareLink {
|
||||
pub id: Uuid,
|
||||
pub media_id: MediaId,
|
||||
pub created_by: UserId,
|
||||
pub token: String,
|
||||
#[serde(skip_serializing)]
|
||||
pub password_hash: Option<String>,
|
||||
pub expires_at: Option<DateTime<Utc>>,
|
||||
pub view_count: u64,
|
||||
pub created_at: DateTime<Utc>,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue