2020-06-24 07:08:31 +00:00
|
|
|
//! # Group membership information
|
|
|
|
//!
|
|
|
|
//! @author Pierre Hubert
|
|
|
|
|
|
|
|
use crate::data::user::UserID;
|
|
|
|
use crate::data::group_id::GroupID;
|
|
|
|
|
2020-06-24 12:08:46 +00:00
|
|
|
#[derive(PartialEq, Eq)]
|
2020-06-24 07:08:31 +00:00
|
|
|
pub enum GroupMembershipLevel {
|
|
|
|
ADMINISTRATOR = 0,
|
|
|
|
MODERATOR = 1,
|
|
|
|
MEMBER = 2,
|
|
|
|
INVITED = 3,
|
|
|
|
PENDING = 4, //When the group membership has not been approved yet
|
|
|
|
VISITOR = 5, //Simple visit
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:16:20 +00:00
|
|
|
impl GroupMembershipLevel {
|
|
|
|
pub fn to_api(&self) -> String {
|
|
|
|
match self {
|
|
|
|
GroupMembershipLevel::ADMINISTRATOR => "administrator",
|
|
|
|
GroupMembershipLevel::MODERATOR => "moderator",
|
|
|
|
GroupMembershipLevel::MEMBER => "member",
|
|
|
|
GroupMembershipLevel::INVITED => "invited",
|
|
|
|
GroupMembershipLevel::PENDING => "pending",
|
|
|
|
GroupMembershipLevel::VISITOR => "visitor",
|
|
|
|
}.to_string()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-24 07:08:31 +00:00
|
|
|
pub struct GroupMember {
|
|
|
|
pub id: u64,
|
|
|
|
pub user_id: UserID,
|
|
|
|
pub group_id: GroupID,
|
|
|
|
pub time_create: u64,
|
|
|
|
pub level: GroupMembershipLevel,
|
|
|
|
pub following: bool
|
|
|
|
}
|