1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-20 16:35:17 +00:00

Can get the list of friends

This commit is contained in:
2020-06-29 15:45:26 +02:00
parent bef9dfffbc
commit 3af2a6f58d
8 changed files with 103 additions and 5 deletions

View File

@ -0,0 +1,35 @@
//! # Friend API
//!
//! @author Pierre Hubert
use serde::Serialize;
use crate::api_data::legacy_api_bool::LegacyBool;
use crate::data::friend::Friend;
#[derive(Serialize)]
#[allow(non_snake_case)]
pub struct FriendAPI {
ID_friend: u64,
accepted: LegacyBool,
time_last_activity: u64,
following: LegacyBool,
canPostTexts: bool,
}
impl FriendAPI {
/// Turn a friend object into an API entry
pub fn new(f: &Friend) -> FriendAPI {
FriendAPI {
ID_friend: f.friend_id.id(),
accepted: LegacyBool(f.accepted),
time_last_activity: f.last_activity_time,
following: LegacyBool(f.following),
canPostTexts: f.can_post_texts,
}
}
/// Generate a new list of Friends
pub fn from_list(l: &Vec<Friend>) -> Vec<FriendAPI> {
l.iter().map(Self::new).collect()
}
}

View File

@ -27,4 +27,5 @@ pub mod res_create_group;
pub mod group_api;
pub mod advanced_group_api;
pub mod res_change_group_logo;
pub mod group_member_api;
pub mod group_member_api;
pub mod friend_api;