Add user actions to statuses in search results

This commit is contained in:
silverpill 2022-05-06 18:27:13 +00:00
parent 496db34e45
commit 54c32c5f00

View file

@ -11,7 +11,10 @@ use crate::config::Config;
use crate::errors::{ValidationError, HttpError}; use crate::errors::{ValidationError, HttpError};
use crate::mastodon_api::accounts::types::Account; use crate::mastodon_api::accounts::types::Account;
use crate::mastodon_api::statuses::types::Status; use crate::mastodon_api::statuses::types::Status;
use crate::models::posts::helpers::can_view_post; use crate::models::posts::helpers::{
can_view_post,
get_actions_for_posts,
};
use crate::models::posts::types::Post; use crate::models::posts::types::Post;
use crate::models::profiles::queries::{ use crate::models::profiles::queries::{
search_profile, search_profile,
@ -155,6 +158,7 @@ pub async fn search(
let accounts: Vec<Account> = profiles.into_iter() let accounts: Vec<Account> = profiles.into_iter()
.map(|profile| Account::from_profile(profile, &config.instance_url())) .map(|profile| Account::from_profile(profile, &config.instance_url()))
.collect(); .collect();
get_actions_for_posts(db_client, &current_user.id, posts.iter_mut().collect()).await?;
let statuses: Vec<Status> = posts.into_iter() let statuses: Vec<Status> = posts.into_iter()
.map(|post| Status::from_post(post, &config.instance_url())) .map(|post| Status::from_post(post, &config.instance_url()))
.collect(); .collect();