Add linked posts to notifications
This commit is contained in:
parent
ea424b97a0
commit
da9bd480fb
1 changed files with 14 additions and 5 deletions
|
@ -4,7 +4,7 @@ use tokio_postgres::GenericClient;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::errors::DatabaseError;
|
use crate::errors::DatabaseError;
|
||||||
use crate::models::posts::helpers::add_user_actions;
|
use crate::models::posts::helpers::{add_related_posts, add_user_actions};
|
||||||
use crate::models::posts::queries::{
|
use crate::models::posts::queries::{
|
||||||
RELATED_ATTACHMENTS,
|
RELATED_ATTACHMENTS,
|
||||||
RELATED_LINKS,
|
RELATED_LINKS,
|
||||||
|
@ -155,9 +155,18 @@ pub async fn get_notifications(
|
||||||
let mut notifications: Vec<Notification> = rows.iter()
|
let mut notifications: Vec<Notification> = rows.iter()
|
||||||
.map(Notification::try_from)
|
.map(Notification::try_from)
|
||||||
.collect::<Result<_, _>>()?;
|
.collect::<Result<_, _>>()?;
|
||||||
let posts = notifications.iter_mut()
|
add_related_posts(
|
||||||
.filter_map(|item| item.post.as_mut())
|
db_client,
|
||||||
.collect();
|
notifications.iter_mut()
|
||||||
add_user_actions(db_client, recipient_id, posts).await?;
|
.filter_map(|item| item.post.as_mut())
|
||||||
|
.collect(),
|
||||||
|
).await?;
|
||||||
|
add_user_actions(
|
||||||
|
db_client,
|
||||||
|
recipient_id,
|
||||||
|
notifications.iter_mut()
|
||||||
|
.filter_map(|item| item.post.as_mut())
|
||||||
|
.collect(),
|
||||||
|
).await?;
|
||||||
Ok(notifications)
|
Ok(notifications)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue