1
0
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:
2020-07-02 18:19:04 +02:00
parent d195979c18
commit 4ab5b9d3e3
11 changed files with 209 additions and 3 deletions

View File

@ -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
View 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()
}
}