mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-22 13:29:21 +00:00
Load like information
This commit is contained in:
parent
532bd9e48d
commit
cab3954edc
@ -8,7 +8,8 @@ use crate::api_data::survey_api::SurveyAPI;
|
||||
use crate::data::error::ResultBoxError;
|
||||
use crate::data::post::{Post, PostKind};
|
||||
use crate::data::user::UserID;
|
||||
use crate::helpers::{movies_helper, survey_helper};
|
||||
use crate::helpers::{likes_helper, movies_helper, survey_helper};
|
||||
use crate::helpers::likes_helper::LikeType;
|
||||
use crate::utils::user_data_utils::user_data_url;
|
||||
|
||||
#[derive(Serialize)]
|
||||
@ -44,6 +45,10 @@ pub struct PostAPI {
|
||||
|
||||
// Survey specific
|
||||
data_survey: Option<SurveyAPI>,
|
||||
|
||||
// Likes information
|
||||
likes: u64,
|
||||
userlike: bool,
|
||||
}
|
||||
|
||||
impl PostAPI {
|
||||
@ -80,6 +85,13 @@ impl PostAPI {
|
||||
|
||||
// Survey specific
|
||||
data_survey: None,
|
||||
|
||||
// Likes information
|
||||
likes: likes_helper::count(p.id, LikeType::POST)? as u64,
|
||||
userlike: user
|
||||
.as_ref()
|
||||
.map(|user_id| likes_helper::is_liking(user_id, p.id, LikeType::POST))
|
||||
.unwrap_or(Ok(false))?,
|
||||
};
|
||||
|
||||
match &p.kind {
|
||||
|
Loading…
Reference in New Issue
Block a user