mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 16:35:17 +00:00
Add likes to export
This commit is contained in:
@ -6,6 +6,7 @@ use serde::Serialize;
|
||||
use crate::api_data::comment_api::CommentAPI;
|
||||
use crate::api_data::post_api::PostAPI;
|
||||
use crate::api_data::user_info::APIUserInfo;
|
||||
use crate::api_data::user_like_api::UserLikeAPI;
|
||||
use crate::data::account_export::AccountExport;
|
||||
use crate::data::error::ResultBoxError;
|
||||
|
||||
@ -16,6 +17,7 @@ pub struct AccountExportAPI {
|
||||
advanced_info: APIUserInfo,
|
||||
posts: Vec<PostAPI>,
|
||||
comments: Vec<CommentAPI>,
|
||||
likes: Vec<UserLikeAPI>,
|
||||
}
|
||||
|
||||
impl AccountExportAPI {
|
||||
@ -26,6 +28,7 @@ impl AccountExportAPI {
|
||||
advanced_info: APIUserInfo::new_advanced_info(&curr_user_id.as_option(), &export.user)?,
|
||||
posts: PostAPI::for_list(&export.posts, curr_user_id.as_option())?,
|
||||
comments: CommentAPI::for_list(&export.comments, &curr_user_id.as_option())?,
|
||||
likes: UserLikeAPI::for_list(&export.likes),
|
||||
};
|
||||
|
||||
Ok(export)
|
||||
|
@ -47,4 +47,5 @@ pub mod res_check_email_exists;
|
||||
pub mod res_check_security_questions_exists;
|
||||
pub mod res_get_security_questions;
|
||||
pub mod res_check_security_answers;
|
||||
pub mod account_export_api;
|
||||
pub mod account_export_api;
|
||||
pub mod user_like_api;
|
32
src/api_data/user_like_api.rs
Normal file
32
src/api_data/user_like_api.rs
Normal file
@ -0,0 +1,32 @@
|
||||
//! # User like API entry
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::data::user_like::UserLike;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct UserLikeAPI {
|
||||
id: u64,
|
||||
user_id: u64,
|
||||
time_sent: u64,
|
||||
elem_type: String,
|
||||
elem_id: u64,
|
||||
}
|
||||
|
||||
impl UserLikeAPI {
|
||||
pub fn new(l: &UserLike) -> UserLikeAPI {
|
||||
UserLikeAPI {
|
||||
id: l.id,
|
||||
user_id: l.user_id.id(),
|
||||
time_sent: l.time_sent,
|
||||
elem_type: l.elem_type.clone(),
|
||||
elem_id: l.elem_id,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn for_list(l: &Vec<UserLike>) -> Vec<UserLikeAPI> {
|
||||
l.iter().map(Self::new).collect()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user