mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-03 17:14:03 +00:00 
			
		
		
		
	Can get the list of friends
This commit is contained in:
		
							
								
								
									
										35
									
								
								src/api_data/friend_api.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								src/api_data/friend_api.rs
									
									
									
									
									
										Normal 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()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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;
 | 
			
		||||
		Reference in New Issue
	
	Block a user