feat: add optional mood to thoughts with custom moods support
Mood is an optional label+emoji string (e.g. "relaxed 😌") on thoughts.
Users can define up to 8 custom moods in profile settings.
Mood federates via AP Note JSON and displays on thought cards.
This commit is contained in:
@@ -36,6 +36,7 @@ struct FeedRow {
|
||||
thought_created_at: DateTime<Utc>,
|
||||
thought_updated_at: Option<DateTime<Utc>>,
|
||||
note_extensions: Option<serde_json::Value>,
|
||||
mood: Option<String>,
|
||||
#[sqlx(flatten)]
|
||||
author: postgres::user::UserRow,
|
||||
like_count: i64,
|
||||
@@ -58,9 +59,9 @@ fn feed_select(viewer: Option<uuid::Uuid>) -> String {
|
||||
t.id AS thought_id, t.user_id AS t_user_id, t.content,\n\
|
||||
t.in_reply_to_id,\n\
|
||||
t.visibility, t.content_warning, t.sensitive, t.local AS t_local,\n\
|
||||
t.created_at AS thought_created_at, t.updated_at AS thought_updated_at, t.note_extensions,\n\
|
||||
t.created_at AS thought_created_at, t.updated_at AS thought_updated_at, t.note_extensions, t.mood,\n\
|
||||
u.id, u.username, u.email, u.password_hash,\n\
|
||||
u.display_name, u.bio, u.avatar_url, u.header_url, u.custom_css, u.profile_fields,\n\
|
||||
u.display_name, u.bio, u.avatar_url, u.header_url, u.custom_css, u.profile_fields, u.custom_moods,\n\
|
||||
u.local,\n\
|
||||
u.created_at, u.updated_at,\n\
|
||||
(SELECT COUNT(*) FROM likes l WHERE l.thought_id=t.id) AS like_count,\n\
|
||||
@@ -84,6 +85,7 @@ fn row_to_entry(r: FeedRow, viewer: Option<uuid::Uuid>) -> Result<FeedEntry, Dom
|
||||
created_at: r.thought_created_at,
|
||||
updated_at: r.thought_updated_at,
|
||||
note_extensions: r.note_extensions,
|
||||
mood: r.mood,
|
||||
};
|
||||
let author = User::from(r.author);
|
||||
Ok(FeedEntry {
|
||||
|
||||
@@ -27,6 +27,7 @@ async fn seed_thought(pool: &sqlx::PgPool, username: &str, content: &str) -> (Us
|
||||
visibility: Visibility::Public,
|
||||
content_warning: None,
|
||||
sensitive: false,
|
||||
mood: None,
|
||||
});
|
||||
trepo.save(&t).await.unwrap();
|
||||
(u, t)
|
||||
|
||||
Reference in New Issue
Block a user