feat: mentions in lives_with and text_body fields
Some checks failed
/ integration-test--firefox (push) Failing after 3m7s
Some checks failed
/ integration-test--firefox (push) Failing after 3m7s
This commit is contained in:
parent
fd5f1899c1
commit
d42adbe274
10 changed files with 369 additions and 200 deletions
|
|
@ -9,6 +9,7 @@ use super::Layout;
|
|||
use crate::db::DbId;
|
||||
use crate::models::user::AuthSession;
|
||||
use crate::models::{Birthday, HydratedContact, JournalEntry};
|
||||
use crate::switchboard::{MentionHost, MentionHostType};
|
||||
use crate::{AppError, AppState};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -109,7 +110,7 @@ pub async fn journal_section(
|
|||
|
||||
.entries {
|
||||
@for entry in entries {
|
||||
(entry.to_html(pool).await?)
|
||||
(Into::<MentionHost>::into(entry).format_pool(pool).await?)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -124,18 +125,22 @@ pub mod get {
|
|||
State(state): State<AppState>,
|
||||
layout: Layout,
|
||||
) -> Result<impl IntoResponse, AppError> {
|
||||
let pool = &state.db(&auth_session.user.unwrap()).pool;
|
||||
let user = auth_session.user.unwrap();
|
||||
let pool = &state.db(&user).pool;
|
||||
|
||||
let contacts: Vec<HydratedContact> = sqlx::query_as(
|
||||
"select id, birthday, manually_freshened_at, (
|
||||
select string_agg(name,'\x1c' order by sort)
|
||||
from names where contact_id = c.id
|
||||
) as names, (
|
||||
select jes.date from journal_entries jes
|
||||
join journal_mentions cms on cms.entry_id = jes.id
|
||||
where cms.url = '/contact/'||c.id
|
||||
join mentions ms on ms.entity_id = jes.id
|
||||
where ms.entity_type = $1
|
||||
and ms.url = '/contact/'||c.id
|
||||
order by jes.date desc limit 1
|
||||
) as last_mention_date from contacts c",
|
||||
)
|
||||
.bind(MentionHostType::JournalEntry as DbId)
|
||||
.fetch_all(pool)
|
||||
.await?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue