mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-07-03 22:45:01 +00:00
Administrators can get information about a single user
This commit is contained in:
@ -2,13 +2,13 @@
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
|
||||
use crate::data::user::{UserID, UserPageStatus};
|
||||
use crate::data::user::{UserID, UserPageVisibility};
|
||||
|
||||
pub struct GeneralSettings {
|
||||
pub id: UserID,
|
||||
pub first_name: String,
|
||||
pub last_name: String,
|
||||
pub page_status: UserPageStatus,
|
||||
pub page_status: UserPageVisibility,
|
||||
pub block_comments: bool,
|
||||
pub allow_posts_from_friends: bool,
|
||||
pub friends_list_public: bool,
|
||||
|
@ -62,12 +62,22 @@ impl PartialEq<UserID> for &UserID {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum UserPageStatus {
|
||||
pub enum UserPageVisibility {
|
||||
OPEN,
|
||||
PUBLIC,
|
||||
PRIVATE,
|
||||
}
|
||||
|
||||
impl UserPageVisibility {
|
||||
pub fn to_api(&self) -> &'static str {
|
||||
match self {
|
||||
UserPageVisibility::OPEN => "open",
|
||||
UserPageVisibility::PUBLIC => "public",
|
||||
UserPageVisibility::PRIVATE => "private"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub enum AccountImageVisibility {
|
||||
@ -110,7 +120,7 @@ pub struct User {
|
||||
pub first_name: String,
|
||||
pub last_name: String,
|
||||
pub last_activity: u64,
|
||||
pub status: UserPageStatus,
|
||||
pub user_page_visibility: UserPageVisibility,
|
||||
pub virtual_directory: Option<String>,
|
||||
pub account_image_path: Option<String>,
|
||||
pub account_image_visibility: AccountImageVisibility,
|
||||
@ -151,12 +161,12 @@ impl User {
|
||||
|
||||
/// Check if user's page is public
|
||||
pub fn is_page_public(&self) -> bool {
|
||||
!matches!(self.status, UserPageStatus::PRIVATE)
|
||||
!matches!(self.user_page_visibility, UserPageVisibility::PRIVATE)
|
||||
}
|
||||
|
||||
/// Check if user's page is open
|
||||
pub fn is_page_open(&self) -> bool {
|
||||
matches!(self.status, UserPageStatus::OPEN)
|
||||
matches!(self.user_page_visibility, UserPageVisibility::OPEN)
|
||||
}
|
||||
|
||||
/// Get the URL pointing to the default account image
|
||||
|
Reference in New Issue
Block a user