add: profiles ui, communities ui, posts ui
This commit is contained in:
parent
00abbc8fa2
commit
eecf357325
36 changed files with 1460 additions and 147 deletions
|
@ -45,6 +45,12 @@ impl Default for UserSettings {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for User {
|
||||
fn default() -> Self {
|
||||
Self::new("<unknown>".to_string(), String::new())
|
||||
}
|
||||
}
|
||||
|
||||
impl User {
|
||||
/// Create a new [`User`].
|
||||
pub fn new(username: String, password: String) -> Self {
|
||||
|
@ -70,6 +76,15 @@ impl User {
|
|||
}
|
||||
}
|
||||
|
||||
/// Deleted user profile.
|
||||
pub fn deleted() -> Self {
|
||||
Self {
|
||||
username: "<deleted>".to_string(),
|
||||
id: 0,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new token
|
||||
///
|
||||
/// # Returns
|
||||
|
|
|
@ -18,8 +18,11 @@ pub struct Community {
|
|||
/// The owner of the community page (and moderators) are the ***only*** people
|
||||
/// capable of removing posts.
|
||||
pub write_access: CommunityWriteAccess,
|
||||
// likes
|
||||
pub likes: isize,
|
||||
pub dislikes: isize,
|
||||
// counts
|
||||
pub member_count: usize,
|
||||
}
|
||||
|
||||
impl Community {
|
||||
|
@ -31,25 +34,31 @@ impl Community {
|
|||
.parse::<usize>()
|
||||
.unwrap(),
|
||||
created: unix_epoch_timestamp() as usize,
|
||||
title,
|
||||
context: CommunityContext::default(),
|
||||
title: title.clone(),
|
||||
context: CommunityContext {
|
||||
display_name: title,
|
||||
..Default::default()
|
||||
},
|
||||
owner,
|
||||
read_access: CommunityReadAccess::default(),
|
||||
write_access: CommunityWriteAccess::default(),
|
||||
likes: 0,
|
||||
dislikes: 0,
|
||||
member_count: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct CommunityContext {
|
||||
pub display_name: String,
|
||||
pub description: String,
|
||||
}
|
||||
|
||||
impl Default for CommunityContext {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
display_name: String::new(),
|
||||
description: String::new(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ bitflags! {
|
|||
pub struct FinePermission: u32 {
|
||||
const DEFAULT = 1 << 0;
|
||||
const ADMINISTRATOR = 1 << 1;
|
||||
const MANAGE_COMMUNITY_PAGES = 1 << 2;
|
||||
const MANAGE_COMMUNITY_ENTRIES = 1 << 3;
|
||||
const MANAGE_COMMUNITIES = 1 << 2;
|
||||
const MANAGE_POSTS = 1 << 3;
|
||||
const MANAGE_POST_REPLIES = 1 << 4;
|
||||
const MANAGE_USERS = 1 << 5;
|
||||
const MANAGE_BANS = 1 << 6; // includes managing IP bans
|
||||
|
@ -106,8 +106,8 @@ impl FinePermission {
|
|||
|
||||
/// Check if the given [`FinePermission`] qualifies as "Helper" status.
|
||||
pub fn check_helper(self) -> bool {
|
||||
self.check(FinePermission::MANAGE_COMMUNITY_ENTRIES)
|
||||
&& self.check(FinePermission::MANAGE_COMMUNITY_PAGES)
|
||||
self.check(FinePermission::MANAGE_COMMUNITIES)
|
||||
&& self.check(FinePermission::MANAGE_POSTS)
|
||||
&& self.check(FinePermission::MANAGE_POST_REPLIES)
|
||||
&& self.check(FinePermission::MANAGE_WARNINGS)
|
||||
&& self.check(FinePermission::VIEW_REPORTS)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue