mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 16:35:17 +00:00
Start to implement post logic
This commit is contained in:
@ -29,4 +29,5 @@ pub mod advanced_group_api;
|
||||
pub mod res_change_group_logo;
|
||||
pub mod group_member_api;
|
||||
pub mod friend_api;
|
||||
pub mod friendship_status_api;
|
||||
pub mod friendship_status_api;
|
||||
pub mod post_api;
|
26
src/api_data/post_api.rs
Normal file
26
src/api_data/post_api.rs
Normal file
@ -0,0 +1,26 @@
|
||||
//! # Post API entry
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::data::post::Post;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[allow(non_snake_case)]
|
||||
pub struct PostAPI {
|
||||
ID: u64,
|
||||
}
|
||||
|
||||
impl PostAPI {
|
||||
/// Turn a `Post` entry into an API entry
|
||||
pub fn new(p: &Post) -> PostAPI {
|
||||
PostAPI {
|
||||
ID: p.id
|
||||
}
|
||||
}
|
||||
|
||||
/// Turn a list of posts into an API entry
|
||||
pub fn for_list(l: &Vec<Post>) -> Vec<PostAPI> {
|
||||
l.iter().map(Self::new).collect()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user